﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;

namespace weiqijiance.安检仪表
{
    public partial class TESTFL : Form
    {

        public string sshebei = "平板";
        public string sdetid;
        public mainform m_mainform;
        public 控制流程.flowcrtl flowbass = new 控制流程.flowcrtl();

        public Thread t1;
        public Thread t2;
        private delegate void FlushClient();//代理

        public bool jcxjs = false;//检测线结束标识
        public bool ssxt = false;//拍照采用双摄像头
        public string revert = "";

        #region 控件大小随窗体大小等比例缩放
        private float x;//定义当前窗体的宽度
        private float y;//定义当前窗体的高度
        private void setTag(Control cons)
        {
            foreach (Control con in cons.Controls)
            {
                con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
                if (con.Controls.Count > 0)
                {
                    setTag(con);
                }
            }
        }
        private void setControls(float newx, float newy, Control cons)
        {
            //遍历窗体中的控件，重新设置控件的值
            foreach (Control con in cons.Controls)
            {
                //获取控件的Tag属性值，并分割后存储字符串数组
                if (con.Tag != null)
                {
                    string[] mytag = con.Tag.ToString().Split(new char[] { ';' });
                    //根据窗体缩放的比例确定控件的值
                    con.Width = Convert.ToInt32(System.Convert.ToSingle(mytag[0]) * newx);//宽度
                    con.Height = Convert.ToInt32(System.Convert.ToSingle(mytag[1]) * newy);//高度
                    con.Left = Convert.ToInt32(System.Convert.ToSingle(mytag[2]) * newx);//左边距
                    con.Top = Convert.ToInt32(System.Convert.ToSingle(mytag[3]) * newy);//顶边距
                    Single currentSize = System.Convert.ToSingle(mytag[4]) * newy;//字体大小
                    con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
                    if (con.Controls.Count > 0)
                    {
                        setControls(newx, newy, con);
                    }
                }
            }
        }
         public int  panel_Width;
         public int panel_Height;    
        void Form1_Resize(object sender, EventArgs e)
        {
            float newx = (panel_Width) / x;
            float newy = (panel_Height) / y;
            setControls(newx, newy, this);
        }
        #endregion

        public TESTFL(int Width, int Height)
        {
            InitializeComponent();
            panel_Width = Width;
            panel_Height = Height;
            init();
            this.Resize += new EventHandler(Form1_Resize);
            x = this.Width;
            y = this.Height;
            setTag(this);
            //Form1_Resize(new object(), new EventArgs());//x,y可在实例化时赋值,最后这句是新加的，在MDI时有用
                //this.WindowState = FormWindowState.Maximized;
            gettongdao();
            xinxixianshi.Text = "平板制动检测";
        }

        private void TESTFL_Load(object sender, EventArgs e)
        {
          
        }

        public void timerstart()
        {
            timer1.Enabled = true;
        }
        public void end()
        {

            flowbass.izhuangtai = 0;
            flowbass.sendend("E", flowbass.sDetectID);
            //closeform();
        }
        private void closeform()
        {
            if (this.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(closeform);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.Dispose();
                this.Close();
            }
        }
        private void openformfl()
        {
            if (this.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(openformfl);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.ShowDialog();
            }
        }

        int m_StartWei = 0;
        int m_dLimitTime=0;
        int xssj = 0;
        public void init()
        {
            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            int.TryParse(objini.ReadValue("平板", "开始重量").Trim(), out m_StartWei);
            if (m_StartWei < 1)
            {
                m_StartWei = 50;
            }
            int.TryParse(objini.ReadValue("平板", "检测时间").Trim(), out m_dLimitTime);
            if (m_dLimitTime < 1)
            {
                m_dLimitTime = 5000;
            }

      
            int.TryParse(objini.ReadValue("制动", "信息显示时间").Trim(), out xssj);
            if (xssj < 1)
                xssj = 1000;
           
            jcxjs = (objini.ReadValue("平板", "检测线结束设备").Trim() == "1") ? true : false;
            ssxt = (objini.ReadValue("平板", "采用双摄像头").Trim() == "1") ? true : false;
            
        }

        public int iFLHWQ = -1;//接入红外信号前
        public int iFLHWH = -1;//接入红外信号后
        //红外取反
        public bool[] bhongwaiqf = new bool[16] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false };//红外是否取反
        //红外定位时间
        public int[] ihongwaidwsj = new int[16] { 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000 };//红外定位时间单位毫秒
      
        //临时变量，用于读取实时数据
        public double dAIlunzhongzuo1 = 0;
        public double dAIlunzhongzuo2 = 0;
        public double dAIlunzhongyuo1 = 0;
        public double dAIlunzhongyuo2 = 0;
        public double dAIzhidongzuo1 = 0;
        public double dAIzhidongzuo2 = 0;
        public double dAIzhidongyuo1 = 0;
        public double dAIzhidongyuo2 = 0;
        //--------------------------------------

        //信号通道
        public int iAIlunzhongzuo1 = 0;
        public int iAIlunzhongzuo2 = 0;
        public int iAIlunzhongyuo1 = 0;
        public int iAIlunzhongyuo2 = 0;

        public int iAIzhidongzuo1 = 0;
        public int iAIzhidongzuo2 = 0;
        public int iAIzhidongyuo1 = 0;
        public int iAIzhidongyuo2 = 0;
        //--------------------------------------
        //刷新窗体控件的变量 
        public double xsdlunzhongzuo1 = 0;
        public double xsdlunzhongzuo2 = 0;
        public double xsdlunzhongyuo1 = 0;
        public double xsdlunzhongyuo2 = 0;
        public double xsdzhidongzuo1 = 0;
        public double xsdzhidongzuo2 = 0;
        public double xsdzhidongyuo1 = 0;
        public double xsdzhidongyuo2 = 0;
        //---------------------------------------------------------
        //检测数据变量，用于上传与存入数据库
        public double dlunzhongzuo1 = 0;
        public double dlunzhongzuo2 = 0;
        public double dlunzhongyuo1 = 0;
        public double dlunzhongyuo2 = 0;

        public double dzhidongzuo1 = 0;
        public double dzhidongzuo2 = 0;
        public double dzhidongyuo1 = 0;
        public double dzhidongyuo2 = 0;
        
        public double dtdlunzhongzuo1 = 0;
        public double dtdlunzhongzuo2 = 0;
        public double dtdlunzhongyuo1 = 0;
        public double dtdlunzhongyuo2 = 0;
        //制动差
        public double dzhidongchazuo1 = 0;
        public double dzhidongchayuo1 = 0;
        public double dzhidongchazuo2 = 0;
        public double dzhidongchayou2 = 0;
        //制动力曲线，联网上传用
        string[] szdqxsj = new string[2];
        //手刹力
        public double dshoushazuo = 0;
        public double dshoushayuo = 0;

        //--------------------------------------------
        public void gettongdao()
        {
            iAIlunzhongzuo1 = 0;
            iAIlunzhongzuo2 = 0;
            iAIlunzhongyuo1 = 0;
            iAIlunzhongyuo2 = 0;

            iAIzhidongzuo1 = 0;
            iAIzhidongzuo2 = 0;
            iAIzhidongyuo1 = 0;
            iAIzhidongyuo2 = 0;

            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\串口及通道设置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            for (int i = 0; i < 10; i++)
            {
                string sgetname = objini.ReadValue("通道设置", string.Format(@"模拟信号{0}", i + 1));

                if (sgetname.Contains("平板前轮重左"))
                {
                    iAIlunzhongzuo1 = i;
                }

                if (sgetname.Contains("平板后轮重左"))
                {
                    iAIlunzhongzuo2 = i;
                }

                if (sgetname.Contains("平板前轮重右"))
                {
                    iAIlunzhongyuo1 = i;
                }

                if (sgetname.Contains("平板后轮重右"))
                {
                    iAIlunzhongyuo2 = i;
                }

                if (sgetname.Contains("平板前制动左"))
                {

                    iAIzhidongzuo1 = i;
                }

                if (sgetname.Contains("平板后制动左"))
                {
                    iAIzhidongzuo2 = i;
                }

                if (sgetname.Contains("平板前制动右"))
                {
                    iAIzhidongyuo1 = i;
                }

                if (sgetname.Contains("平板后制动右"))
                {
                    iAIzhidongyuo2 = i;
                }
            }

            for (int i = 0; i < 16; i++)
            {


                string shongwai = objini.ReadValue("通道设置", string.Format(@"红外{0}", i + 1));
                if (shongwai.Contains("平板前到位"))
                {
                    iFLHWQ = i;
                }
                if (shongwai.Contains("平板后到位"))
                {
                    iFLHWH = i;
                }
                shongwai = objini.ReadValue("通道设置", string.Format(@"红外定位时间{0}", i + 1));
                int.TryParse(shongwai, out ihongwaidwsj[i]);


                shongwai = objini.ReadValue("通道设置", string.Format(@"红外是否取反{0}", i + 1));
                if (shongwai.Contains("是"))
                {
                    bhongwaiqf[i] = true;
                }
                else
                {
                    bhongwaiqf[i] = false;
                }
            }

        }
        public void StratTest()
        {
            //ShowControls(true);
            flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "平板检测开始", flowbass.sDetectID);
           // m_mainform.DAC.tiaoling(1);
          //  m_mainform.DAC.setsjjl(true, flowbass.sPlate + DateTime.Now.ToString("MMddHHmmss"));//开始记录信号板信息
            flowbass.LedWrite("以5-10 km/h", "驶上平板台", 1);

            sxinxixianshi = "以5-10km/h驶上平板台";
            showxianshi();
            if (!flowbass.bSLTJ)
            {
                //进入检测流程
                if (flowbass.bJCXCZDZ[0])
                {
                    flowbass.LedWrite("以5-10 km/h", "1轴驶上平板台", 1);
                    DetectBrake(1);//
                    if (flowbass.IsCancle())
                    {
                        flowbass.LedWrite("检测取消", "", 1);
                        return;
                    }
                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        JudgeTotalResult38900(1);
                    }
                    else
                    {
                        JudgeTotalResult(1);
                    }
                }
                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }
                if (flowbass.bJCXCZDZ[1])
                {
                    flowbass.LedWrite("以5-10 km/h", "2轴驶上平板台", 1);
                    DetectBrake(2);//
                    if (flowbass.IsCancle())
                    {
                        flowbass.LedWrite("检测取消", "", 1);
                        return;
                    }
                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        JudgeTotalResult38900(2);
                    }
                    else
                    {
                        JudgeTotalResult(2);
                    }
                }
                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }
                if (flowbass.bJCZCZDZ[1])
                {
                    DetectBrakeSHOUSHA();
                    if (flowbass.IsCancle())
                    {
                        flowbass.LedWrite("检测取消", "", 1);
                        return;
                    }
                }
                if (flowbass.bJCXCZDZ[0] || flowbass.bJCXCZDZ[1])
                {
                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        JudgeTotalResult38900(3);
                    }
                    else
                    {
                        JudgeTotalResult(3);
                    }
                    if (flowbass.IsCancle())
                    {
                        flowbass.LedWrite("检测取消", "", 1);
                        return;
                    }
                }
            }
            else//四轮同检流程 字段被干掉了
            {
                flowbass.LedWrite("以5-10 km/h", "四轮同检", 1);
                sxinxixianshi = "以5-10km/h驶上平板台";
                showxianshi();
                //进入检测流程
                if (flowbass.bJCXCZDZ[0] || flowbass.bJCXCZDZ[1])
                {
                    DetectBrakeALL();//四轮同检流程
                    if (flowbass.IsCancle())
                    {
                        flowbass.LedWrite("检测取消", "", 1);
                        return;
                    }
                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        JudgeTotalResult38900(0);
                    }
                    else
                    {
                        JudgeTotalResult(0);
                    }
                    if (flowbass.IsCancle())
                    {
                        flowbass.LedWrite("检测取消", "", 1);
                        return;
                    }
                }
                if (flowbass.bJCZCZDZ[1])
                {
                    DetectBrakeSHOUSHA();
                    if (flowbass.IsCancle())
                    {
                        flowbass.LedWrite("检测取消", "", 1);
                        return;
                    }
                }
            }
           // m_mainform.DAC.setsjjl(false, flowbass.sPlate + DateTime.Now.ToString("MMddHHmmss"));//开始记录信号板信息

            
        }
        List<double> listlzz1=new List<double>();
        List<double> listlzy1=new List<double>();
        List<double> listlzz2=new List<double>();
        List<double> listlzy2=new List<double>();
        
        List<double> listzdz1=new List<double>();
        List<double> listzdy1=new List<double>();
        List<double> listzdz2=new List<double>();
        List<double> listzdy2=new List<double>();
        /// <summary>
        /// 四轮同检流程
        /// </summary>
        public void DetectBrakeALL()
        {
            flowbass.objcarclass.tongdao1 = flowbass.ipbzdqtongdao.ToString();
            flowbass.objcarclass.tongdao2 = flowbass.ipbzdhtongdao.ToString();

            flowbass.LedWrite("四轮同检", "驶上平板台", 1);

            string[] pic_br = new string[5] { "0322", "0348", "0349", "0350", "0354" };
            string[] pic_br38900 = new string[2] { "A309", "A310" };
            string[] pic_we38900 = new string[2] { "A307", "A308" };
            string[] pic_ss38900 = new string[2] { "A316", "A317" };
            listlzz1 = new List<double>();
            listlzy1 = new List<double>();
            listlzz2 = new List<double>();
            listlzy2 = new List<double>();

            listzdz1 = new List<double>();
            listzdy1 = new List<double>();
            listzdz2 = new List<double>();
            listzdy2 = new List<double>();
            //////////////制动变量
            int uMaxSub = 0, uBrakePointL = 0, uBrakePointR = 0, uMaxSum = 0, uMinSum = 0;
           
            int iMaxBrLPoint = 0;
            int iMaxBrRPoint = 0;
            int iMinBrLPoint = 0;//第一取值点

            int uMaxSub2 = 0, uBrakePointL2 = 0, uBrakePointR2 = 0, uMaxSum2 = 0, uMinSum2 = 0;
           
            int iMaxBrLPoint2 = 0;
            int iMaxBrRPoint2 = 0;
            int iMinBrLPoint2 = 0;//第一取值点

            bool chufahongwai = false;
            if (flowbass.bnj)//综检不传
            {
                flowbass.LedWrite("正在发送", "联网开始", 1);
                sxinxixianshi = "正在发送联网开始";
                showxianshi();

                if (flowbass.sjcbz.Contains("38900"))
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("PBB1", "开始", flowbass.gwjysbbh, flowbass.ipbzdqtongdao.ToString(), flowbass.objcarclass);
                }
                else
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("STB1", "开始", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                }
                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                }
                if (flowbass.sjcbz.Contains("38900"))
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("PBB2", "开始", flowbass.gwjysbbh, flowbass.ipbzdhtongdao.ToString(), flowbass.objcarclass);
                }
                else
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("STB2", "开始", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                }
                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                }
            }

            flowbass.LedWrite("四轮同检", "开始检测", 1);
            sxinxixianshi = "四轮同检开始检测";
            showxianshi();
            List<double> listlzzlscyz1 = new List<double>();
            List<double> listlzylscyz1 = new List<double>();
            List<double> listzdzlscyz1 = new List<double>();
            List<double> listzdylscyz1 = new List<double>();
            List<double> listlzzlscyz2 = new List<double>();
            List<double> listlzylscyz2 = new List<double>();
            List<double> listzdzlscyz2 = new List<double>();
            List<double> listzdylscyz2 = new List<double>();

            List<double> lslistlzzlscyz1 = new List<double>();
            List<double> lslistlzylscyz1 = new List<double>();
            List<double> lslistzdzlscyz1 = new List<double>();
            List<double> lslistzdylscyz1 = new List<double>();
            List<double> lslistlzzlscyz2 = new List<double>();
            List<double> lslistlzylscyz2 = new List<double>();
            List<double> lslistzdzlscyz2 = new List<double>();
            List<double> lslistzdylscyz2 = new List<double>();
            //#region
            DateTime start = DateTime.Now;
            #region 车子开过红外或重量大于设置的开始重量
            while(true)
            {

                if (m_mainform.WaitEventZT(iFLHWQ, bhongwaiqf[iFLHWQ], ihongwaidwsj[iFLHWQ]))
                {
                    chufahongwai = true;
                    break;
                    
                }
                dAIlunzhongzuo1 = m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo1]) - m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo1]);
                dAIlunzhongyuo1 = m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo1]) - m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo1]);

                dAIzhidongzuo1 = m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo1]) - m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo1]);
                dAIzhidongyuo1 = m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo1]) - m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo1]);

                dAIlunzhongzuo1 = Math.Round(dAIlunzhongzuo1);
                dAIlunzhongyuo1 = Math.Round(dAIlunzhongyuo1);

                dAIzhidongzuo1 = Math.Round(dAIzhidongzuo1);
                dAIzhidongyuo1 = Math.Round(dAIzhidongyuo1);

                //后板轮重或者后板制动大于设置的开始重量，退出循环，进入流程
                if ((((dAIlunzhongyuo1 + dAIlunzhongzuo1) > m_StartWei) || ((dAIzhidongzuo1 + dAIzhidongyuo1) > m_StartWei))&&chufahongwai)
                {
                    flowbass.LedWrite("请踩刹车", "", 1);
                    break;
                }
                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }
                if (m_mainform.DateDiff(DateTime.Now, start) > (400))
                {
                    start = DateTime.Now;
                    listlzzlscyz1.Add(m_mainform.DAC.fAIData[iAIlunzhongzuo1]);
                    listlzylscyz1.Add(m_mainform.DAC.fAIData[iAIlunzhongyuo1]);
                    listzdzlscyz1.Add(m_mainform.DAC.fAIData[iAIzhidongzuo1]);
                    listzdylscyz1.Add(m_mainform.DAC.fAIData[iAIzhidongyuo1]);
                    listlzzlscyz2.Add(m_mainform.DAC.fAIData[iAIlunzhongzuo2]);
                    listlzylscyz2.Add(m_mainform.DAC.fAIData[iAIlunzhongyuo2]);
                    listzdzlscyz2.Add(m_mainform.DAC.fAIData[iAIzhidongzuo2]);
                    listzdylscyz2.Add(m_mainform.DAC.fAIData[iAIzhidongyuo2]);
                }
                Thread.Sleep(10);
            }
            #endregion
            DateTime dtimestart = DateTime.Now;
            #region 制动检测流程（包括动态轮重）

            flowbass.LedWrite("检测开始", "", 1);
            while (true)
            {
                Debug.WriteLine(string.Format("采样值时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "1"));

                listlzzlscyz1.Add(m_mainform.DAC.fAIData[iAIlunzhongzuo1]);
                listlzylscyz1.Add(m_mainform.DAC.fAIData[iAIlunzhongyuo1]);
                listzdzlscyz1.Add(m_mainform.DAC.fAIData[iAIzhidongzuo1]);
                listzdylscyz1.Add(m_mainform.DAC.fAIData[iAIzhidongyuo1]);
                listlzzlscyz2.Add(m_mainform.DAC.fAIData[iAIlunzhongzuo2]);
                listlzylscyz2.Add(m_mainform.DAC.fAIData[iAIlunzhongyuo2]);
                listzdzlscyz2.Add(m_mainform.DAC.fAIData[iAIzhidongzuo2]);
                listzdylscyz2.Add(m_mainform.DAC.fAIData[iAIzhidongyuo2]);

                ////保证时间
                //if (m_mainform.DateDiff(DateTime.Now, dtimestart) > (m_dLimitTime))// 检测5秒
                //{
                //    break;
                //}
                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }

                //保证时间
                double test;
                test = m_mainform.DateDiff(DateTime.Now, dtimestart);
                if (test > (m_dLimitTime))// 检测5秒
                {
                    break;
                }
                Thread.Sleep(10);
                Debug.WriteLine(string.Format("采样值时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "2"));
            }
            for(int i=0;i<listlzzlscyz1.Count;i++)
            {
                dAIlunzhongzuo1 = m_mainform.DAC.getjsz("平板前轮重左",(float)listlzzlscyz1[i]) - m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo1]);
                dAIlunzhongyuo1 = m_mainform.DAC.getjsz("平板前轮重右",(float)listlzylscyz1[i]) - m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo1]);
                dAIzhidongzuo1 =  m_mainform.DAC.getjsz("平板前制动左",(float)listzdzlscyz1[i]) - m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo1]);
                dAIzhidongyuo1 =  m_mainform.DAC.getjsz("平板前制动右",(float)listzdylscyz1[i]) - m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo1]);
                dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左",(float)listlzzlscyz2[i]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
                dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右",(float)listlzylscyz2[i]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);
                dAIzhidongzuo2 =  m_mainform.DAC.getjsz("平板后制动左",(float)listzdzlscyz2[i]) - m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo2]);
                dAIzhidongyuo2 =  m_mainform.DAC.getjsz("平板后制动右",(float)listzdylscyz2[i]) - m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo2]);
                if (dAIlunzhongzuo1 < 0)
                {
                    dAIlunzhongzuo1 = 0;
                }
                if (dAIlunzhongyuo1 < 0)
                {
                    dAIlunzhongyuo1 = 0;
                }
                if (dAIzhidongzuo1 < 0)
                {
                    dAIzhidongzuo1 = 0;
                }
                if (dAIzhidongyuo1 < 0)
                {
                    dAIzhidongyuo1 = 0;
                }
                if (dAIlunzhongzuo2 < 0)
                {
                    dAIlunzhongzuo2 = 0;
                }
                if (dAIlunzhongyuo2 < 0)
                {
                    dAIlunzhongyuo2 = 0;
                }
                if (dAIzhidongzuo2 < 0)
                {
                    dAIzhidongzuo2 = 0;
                }
                if (dAIzhidongyuo2 < 0)
                {
                    dAIzhidongyuo2 = 0;
                }

                dAIlunzhongzuo1 = Math.Round(dAIlunzhongzuo1);
                dAIlunzhongyuo1 = Math.Round(dAIlunzhongyuo1);
                dAIzhidongzuo1 = Math.Round (dAIzhidongzuo1);
                dAIzhidongyuo1 = Math.Round(dAIzhidongyuo1);
                dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
                dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);
                dAIzhidongzuo2 = Math.Round(dAIzhidongzuo2);
                dAIzhidongyuo2 = Math.Round(dAIzhidongyuo2);

                lslistlzzlscyz1.Add(dAIlunzhongzuo1);
                lslistlzylscyz1.Add(dAIlunzhongyuo1);
                lslistzdzlscyz1.Add(dAIzhidongzuo1);
                lslistzdylscyz1.Add(dAIzhidongyuo1);
                lslistlzzlscyz2.Add(dAIlunzhongzuo2);
                lslistlzylscyz2.Add(dAIlunzhongyuo2);
                lslistzdzlscyz2.Add(dAIzhidongzuo2);
                lslistzdylscyz2.Add(dAIzhidongyuo2);
                if (i > 0 && (dAIzhidongzuo1 >= 5 && dAIzhidongyuo1 >= 5 && dAIzhidongzuo2 >= 5 && dAIzhidongyuo2 >= 5))
                {
                    if (Math.Round(dAIzhidongzuo1) == listzdz1[listzdz1.Count - 1] || Math.Round(dAIzhidongyuo1) == listzdy1[listzdy1.Count - 1])
                    {
                        continue;
                    }
                    if (Math.Round(dAIzhidongzuo2) == listzdz2[listzdz2.Count - 1] || Math.Round(dAIzhidongyuo2) == listzdy2[listzdy2.Count - 1])
                    {
                        continue;
                    }
                }


                listlzz1.Add(dAIlunzhongzuo1);
                listlzy1.Add(dAIlunzhongyuo1);
                listlzz2.Add(dAIlunzhongzuo2);
                listlzy2.Add(dAIlunzhongyuo2);

                listzdz1.Add(dAIzhidongzuo1);
                listzdy1.Add(dAIzhidongyuo1);
                listzdz2.Add(dAIzhidongzuo2);
                listzdy2.Add(dAIzhidongyuo2);

                xsdlunzhongzuo1 = dAIlunzhongzuo1;
                xsdlunzhongyuo1 = dAIlunzhongyuo1;
                xsdlunzhongzuo2 = dAIlunzhongzuo2;
                xsdlunzhongyuo2 = dAIlunzhongyuo2;
                xsdzhidongzuo1 = dAIzhidongzuo1;
                xsdzhidongyuo1 = dAIzhidongyuo1;
                xsdzhidongzuo2 = dAIzhidongzuo2;
                xsdzhidongyuo2 = dAIzhidongyuo2;

                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }
                //Thread.Sleep(10);
            }
            #endregion
            #region 制动检测流程（包括动态轮重）
           /* while (true)
            {
                flowbass.LedWrite("检测开始", "", 1);
                dAIlunzhongzuo1 = m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo1]) - m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo1]);
                dAIlunzhongyuo1 = m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo1]) - m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo1]);
                dAIzhidongzuo1 =  m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo1]) - m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo1]);
                dAIzhidongyuo1 =  m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo1]) - m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo1]);
                dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo2]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
                dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo2]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);
                dAIzhidongzuo2 =  m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo2]) - m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo2]);
                dAIzhidongyuo2 =  m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo2]) - m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo2]);
                if (dAIlunzhongzuo1 < 0)
                {
                    dAIlunzhongzuo1 = 0;
                }
                if (dAIlunzhongyuo1 < 0)
                {
                    dAIlunzhongyuo1 = 0;
                }
                if (dAIzhidongzuo1 < 0)
                {
                    dAIzhidongzuo1 = 0;
                }
                if (dAIzhidongyuo1 < 0)
                {
                    dAIzhidongyuo1 = 0;
                }
                if (dAIlunzhongzuo2 < 0)
                {
                    dAIlunzhongzuo2 = 0;
                }
                if (dAIlunzhongyuo2 < 0)
                {
                    dAIlunzhongyuo2 = 0;
                }
                if (dAIzhidongzuo2 < 0)
                {
                    dAIzhidongzuo2 = 0;
                }
                if (dAIzhidongyuo2 < 0)
                {
                    dAIzhidongyuo2 = 0;
                }
                dAIlunzhongzuo1 = Math.Round(dAIlunzhongzuo1);
                dAIlunzhongyuo1 = Math.Round(dAIlunzhongyuo1);
                dAIzhidongzuo1 = Math.Round(dAIzhidongzuo1);
                dAIzhidongyuo1 = Math.Round(dAIzhidongyuo1);
                dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
                dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);
                dAIzhidongzuo2 = Math.Round(dAIzhidongzuo2);
                dAIzhidongyuo2 = Math.Round(dAIzhidongyuo2);

                listlzz1.Add(dAIlunzhongzuo1);
                listlzy1.Add(dAIlunzhongyuo1);
                listlzz2.Add(dAIlunzhongzuo2);
                listlzy2.Add(dAIlunzhongyuo2);

                listzdz1.Add(dAIzhidongzuo1);
                listzdy1.Add(dAIzhidongyuo1);
                listzdz2.Add(dAIzhidongzuo2);
                listzdy2.Add(dAIzhidongyuo2);

                xsdlunzhongzuo1 = dAIlunzhongzuo1;
                xsdlunzhongyuo1 = dAIlunzhongyuo1;
                xsdlunzhongzuo2 = dAIlunzhongzuo2;
                xsdlunzhongyuo2 = dAIlunzhongyuo2;
                xsdzhidongzuo1 = dAIzhidongzuo1;
                xsdzhidongyuo1 = dAIzhidongyuo1;
                xsdzhidongzuo2 = dAIzhidongzuo2;
                xsdzhidongyuo2 = dAIzhidongyuo2;
                showsj();

                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }

                //保证时间
                double test;
                test=m_mainform.DateDiff(DateTime.Now, dtimestart);
                if (test > (m_dLimitTime))// 检测5秒
                {
                    break;
                }
                Thread.Sleep(10);
            }*/
            #endregion

            //showsj();
            if (flowbass.bnj)//综检不传
            {
                if (flowbass.sjcbz.Contains("38900"))
                {
                    flowbass.objajlwbass.sendpic(flowbass.ipbzdqtongdao.ToString(), pic_br38900[0], flowbass.objcarclass);//图片抓拍
                    flowbass.objajlwbass.sendpic(flowbass.ipbzdhtongdao.ToString(), pic_br38900[1], flowbass.objcarclass);//图片抓拍
                    //flowbass.objajlwbass.sendpic(flowbass.ipbzdqtongdao.ToString(), pic_we38900[0], flowbass.objcarclass);//图片抓拍
                    //flowbass.objajlwbass.sendpic(flowbass.ipbzdhtongdao.ToString(), pic_we38900[1], flowbass.objcarclass);//图片抓拍
                }
                else
                {
                    if (ssxt)
                    {
                        flowbass.objajlwbass.sendpic(flowbass.ibrtongdao2.ToString(), pic_br[0], flowbass.objcarclass);//图片抓拍
                        flowbass.objajlwbass.sendpic(flowbass.ibrtongdao.ToString(), pic_br[1], flowbass.objcarclass);//图片抓拍
                    }
                    else
                    {
                        flowbass.objajlwbass.sendpic(flowbass.ibrtongdao.ToString(), pic_br[0], flowbass.objcarclass);//图片抓拍
                        flowbass.objajlwbass.sendpic(flowbass.ibrtongdao.ToString(), pic_br[1], flowbass.objcarclass);//图片抓拍
                    }
                }
            }
            Thread.Sleep(xssj);
            flowbass.LedWrite("制动检测完成", "请松刹车",1);
            sxinxixianshi = "制动检测完成,请松刹车";
            showxianshi();
            Thread.Sleep(xssj);
            #region 曲线平滑处理
            //for (int k = 0; k < 2; k++)
            //{
            //    for (int i = 0; i < listlzz1.Count - 1; i++)
            //    {
            //        listlzz1[i] = Math.Round((listlzz1[i] + listlzz1[i + 1]) / 2);
            //        listlzy1[i] = Math.Round((listlzy1[i] + listlzy1[i + 1]) / 2);
            //        listlzz2[i] = Math.Round((listlzz2[i] + listlzz2[i + 1]) / 2);
            //        listlzy2[i] = Math.Round((listlzy2[i] + listlzy2[i + 1]) / 2);

            //        listzdz1[i] = Math.Round((listzdz1[i] + listzdz1[i + 1]) / 2);
            //        listzdy1[i] = Math.Round((listzdy1[i] + listzdy1[i + 1]) / 2);
            //        listzdz2[i] = Math.Round((listzdz2[i] + listzdz2[i + 1]) / 2);
            //        listzdy2[i] = Math.Round((listzdy2[i] + listzdy2[i + 1]) / 2);

            //    }
            //}



            string qxd;
            //string szdqxsj1 = "10@";
            //string szdqxsj2 = "10@";
            szdqxsj[0] = "10@";
            szdqxsj[1] = "10@";
            for (int icount = 0; icount < listlzz1.Count; icount++)
            {
                string slsqx = "";
                slsqx = string.Format("{0}#{1}$", listzdz1[icount], listzdy1[icount]);
                szdqxsj[0] += slsqx;
                slsqx = string.Format("{0}#{1}$", listzdz2[icount], listzdy2[icount]);
                szdqxsj[1] += slsqx;
            }
            #endregion
            qxd = listlzz1.Count.ToString();

            double fLMax1 = 0;
            double fRMax1 = 0;
            double fLMax2 = 0;
            double fRMax2 = 0;

            double fLMaxWE1 = 0;
            double fRMaxWE1 = 0;
            double fLMaxWE2 = 0;
            double fRMaxWE2 = 0;
            #region 找出最大制动力点
            //找出最大制动力点
            for (int i = 0; i < listlzz1.Count; i++)
            {
                if (listzdz1[i] > fLMax1)
                {
                    fLMaxWE1 = listlzz1[i];
                    fLMax1 = listzdz1[i];
                    iMaxBrLPoint = i;
                }
                if (listzdy1[i] > fRMax1)
                {
                    fRMaxWE1 = listlzy1[i];
                    fRMax1 = listzdy1[i];
                    iMaxBrRPoint = i;
                }
                if (listzdz2[i] > fLMax2)
                {
                    fLMaxWE2 = listlzz2[i];
                    fLMax2 = listzdz2[i];
                    iMaxBrLPoint2 = i;
                }
                if (listzdy2[i] > fRMax2)
                {
                    fRMaxWE2 = listlzy2[i];
                    fRMax2 = listzdy2[i];
                    iMaxBrRPoint2 = i;
                }
            }

            if (iMaxBrLPoint > iMaxBrRPoint)
            {
                iMinBrLPoint = iMaxBrRPoint;//第一个取值点
                iMaxBrRPoint = iMaxBrLPoint;
            }
            else
            {
                iMinBrLPoint = iMaxBrLPoint;//第一个取值点
            }

            if (iMaxBrLPoint2 > iMaxBrRPoint2)
            {
                iMinBrLPoint2 = iMaxBrRPoint2;//第一个取值点
                iMaxBrRPoint2 = iMaxBrLPoint2;
            }
            else
            {
                iMinBrLPoint2 = iMaxBrLPoint2;//第一个取值点
            }

            xsdlunzhongzuo1 = fLMaxWE1;
            xsdlunzhongyuo1 = fRMaxWE1;
            xsdlunzhongzuo2 = fLMaxWE2;
            xsdlunzhongyuo2 = fRMaxWE2;
            xsdzhidongzuo1 = fLMax1;
            xsdzhidongyuo1 = fRMax1;
            xsdzhidongzuo2 = fLMax2;
            xsdzhidongyuo2 = fRMax2;
            showsj();

            dzhidongzuo1 = fLMax1;
            dzhidongyuo1 = fRMax1;
            dzhidongzuo2 = fLMax2;
            dzhidongyuo2 = fRMax2;

            dtdlunzhongzuo1 = fLMaxWE1;
            dtdlunzhongyuo1 = fRMaxWE1;
            dtdlunzhongzuo2 = fLMaxWE2;
            dtdlunzhongyuo2 = fRMaxWE2;

            //赋值制动力
            flowbass.VAX_VBRAKEL[0] = (float)dzhidongzuo1;
            flowbass.VAX_VBRAKER[0] = (float)dzhidongyuo1;
            flowbass.VAX_VBRAKEL[1] = (float)dzhidongzuo2;
            flowbass.VAX_VBRAKER[1] = (float)dzhidongyuo2;
            #endregion


            #region 找最大不平衡力

            uMaxSum = (int)Math.Abs(listzdz1[iMinBrLPoint] + listzdy1[iMinBrLPoint]);//第一取值点和
            uMinSum = (int)Math.Abs(listzdz1[iMinBrLPoint] - listzdy1[iMinBrLPoint]);//第一取值点和
            for (int i = 0; i <= iMaxBrRPoint; i++)
            {
                if (i <= iMinBrLPoint)
                {
                    if (uMaxSub < Math.Abs(listzdz1[i] - listzdy1[i]))
                    {
                        uMaxSub = (int)Math.Abs(listzdz1[i] - listzdy1[i]);
                        uBrakePointL = (int)listzdz1[i];
                        uBrakePointR = (int)listzdy1[i];
                    }
                }
                else
                {
                    if (i < iMinBrLPoint + 2 && uMinSum > Math.Abs(listzdz1[i] - listzdy1[i]))//第一最大点，过程差校验，如果后面比它大继续下去
                    {
                        break;
                    }
                    else
                    {
                        if (uMaxSub < Math.Abs(listzdz1[i] - listzdy1[i]) && uMaxSum < Math.Abs(listzdz1[i] + listzdy1[i]))
                        {
                            uMaxSum = (int)Math.Abs(listzdz1[i] + listzdy1[i]);
                            uMaxSub = (int)Math.Abs(listzdz1[i] - listzdy1[i]);
                            uBrakePointL = (int)listzdz1[i];
                            uBrakePointR = (int)listzdy1[i];
                        }
                    }
                }

            }

            uMaxSum2 = (int)Math.Abs(listzdz2[iMinBrLPoint2] + listzdy2[iMinBrLPoint2]);//第一取值点和
            uMinSum2 = (int)Math.Abs(listzdz2[iMinBrLPoint2] - listzdy2[iMinBrLPoint2]);//第一取值点和
            for (int ii = 0; ii <= iMaxBrRPoint2; ii++)
            {
                if (ii <= iMinBrLPoint2)
                {
                    if (uMaxSub2 < Math.Abs(listzdz2[ii] - listzdy2[ii]))
                    {
                        uMaxSub2 = (int)Math.Abs(listzdz2[ii] - listzdy2[ii]);
                        uBrakePointL2 = (int)listzdz2[ii];
                        uBrakePointR2 = (int)listzdy2[ii];
                    }
                }
                else
                {
                    if (ii < iMinBrLPoint2 + 2 && uMinSum2 > Math.Abs(listzdz2[ii] - listzdy2[ii]))//第一最大点，过程差校验，如果后面比它大继续下去
                    {
                        break;
                    }
                    else
                    {
                        if (uMaxSub2 < Math.Abs(listzdz2[ii] - listzdy2[ii]) && uMaxSum2 < Math.Abs(listzdz2[ii] + listzdy2[ii]))
                        {
                            uMaxSum2 = (int)Math.Abs(listzdz2[ii] + listzdy2[ii]);
                            uMaxSub2 = (int)Math.Abs(listzdz2[ii] - listzdy2[ii]);
                            uBrakePointL2 = (int)listzdz2[ii];
                            uBrakePointR2 = (int)listzdy2[ii];
                        }
                    }
                }
            }
            dzhidongchazuo1= uBrakePointL  ;
            dzhidongchayuo1= uBrakePointR  ;
            dzhidongchazuo2=uBrakePointL2  ;
            dzhidongchayou2 = uBrakePointR2;
            #endregion

            #region 检测轮重
            ///////////////检测轴重
            if (flowbass.bweight)
            {
                //if(bDetWei1 || bDetWei2 || bDetSu1 || bDetSu2)		
                {
                    flowbass.LedWrite("开始检测轮重", "", 1);
                    sxinxixianshi = "开始检测轮重";
                    showxianshi();
                    dtimestart = DateTime.Now;
                    for (; ; )
                    {
                        dAIlunzhongzuo1 = m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo1]) - m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo1]);
                        dAIlunzhongyuo1 = m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo1]) - m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo1]);

                        dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo2]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
                        dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo2]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);
                        dAIlunzhongzuo1 = Math.Round(dAIlunzhongzuo1);
                        dAIlunzhongyuo1 = Math.Round(dAIlunzhongyuo1);

                        dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
                        dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);


                        xsdlunzhongzuo1 = dAIlunzhongzuo1;
                        xsdlunzhongyuo1 = dAIlunzhongyuo1;
                        xsdlunzhongzuo2 = dAIlunzhongzuo2;
                        xsdlunzhongyuo2 = dAIlunzhongyuo2;
                        xsdzhidongzuo1 = dAIzhidongzuo1;
                        xsdzhidongyuo1 = dAIzhidongyuo1;
                        xsdzhidongzuo2 = dAIzhidongzuo2;
                        xsdzhidongyuo2 = dAIzhidongyuo2;
                        showsj();
                        if (flowbass.IsCancle())
                        {
                            flowbass.LedWrite("检测取消", "", 1);
                            return;
                        }
                        //保证时间
                        if (m_mainform.DateDiff(DateTime.Now, dtimestart) > (m_dLimitTime))// 检测5秒
                        {
                            break;
                        }
                        Thread.Sleep(100);

                    }


                    xsdlunzhongzuo1 = dAIlunzhongzuo1;
                    xsdlunzhongyuo1 = dAIlunzhongyuo1;
                    xsdlunzhongzuo2 = dAIlunzhongzuo2;
                    xsdlunzhongyuo2 = dAIlunzhongyuo2;
                    xsdzhidongzuo1 = dAIzhidongzuo1;
                    xsdzhidongyuo1 = dAIzhidongyuo1;
                    xsdzhidongzuo2 = dAIzhidongzuo2;
                    xsdzhidongyuo2 = dAIzhidongyuo2;
                    showsj();
                    dlunzhongzuo1 = dAIlunzhongzuo1;
                    dlunzhongyuo1 = dAIlunzhongyuo1;
                    dlunzhongzuo2 = dAIlunzhongzuo2;
                    dlunzhongyuo2 = dAIlunzhongyuo2;

                    flowbass.VAX_VWGHTLSP[0] = (float)dAIlunzhongzuo1;
                    flowbass.VAX_VWGHTRSP[0] = (float)dAIlunzhongyuo1;
                    flowbass.VAX_VWGHTLSP[1] = (float)dAIlunzhongzuo2;
                    flowbass.VAX_VWGHTRSP[1] = (float)dAIlunzhongyuo2;

                    flowbass.LedWrite("轮重检测结束", "", 1);
                    sxinxixianshi = "轮重检测结束";
                    showxianshi();
                    Thread.Sleep(xssj);

                }
            }
            #endregion


        }

        public bool sdjcs=false;
        public void DetectBrake(int zhou)
        {
            flowbass.objcarclass.tongdao1 = flowbass.ipbzdqtongdao.ToString();
            flowbass.objcarclass.tongdao2 = flowbass.ipbzdhtongdao.ToString();

            string[] pic_br = new string[5] { "0322", "0348", "0349", "0350", "0354" };
            string[] pic_br38900 = new string[2] { "A309", "A310" };
            string[] pic_we38900 = new string[2] { "A307", "A308" };
            string[] pic_ss38900 = new string[2] { "A316", "A317" };
            if (zhou == 1)
            {
                listlzz1 = new List<double>();
                listlzy1 = new List<double>();
                listzdz1 = new List<double>();
                listzdy1 = new List<double>();
            }
            else
            {
                listlzz2 = new List<double>();
                listlzy2 = new List<double>();
                listzdz2 = new List<double>();
                listzdy2 = new List<double>();
            }
            //////////////制动变量
            int uMaxSub = 0, uBrakePointL = 0, uBrakePointR = 0, uMaxSum = 0, uMinSum = 0;
           
            int iMaxBrLPoint = 0;
            int iMaxBrRPoint = 0;
            int iMinBrLPoint = 0;

            int  uBrakePointL2 = 0, uBrakePointR2 = 0;
            
            int iMaxBrLPoint2 = 0;
            int iMaxBrRPoint2 = 0;
            int iMinBrLPoint2 = 0;
            bool hongwai = false;

            string jcxm = "";
            jcxm = string.Format(@"B{0}", zhou);

            if (flowbass.bnj)//综检不传
            {
                flowbass.LedWrite("正在发送", "联网开始", 1);
                sxinxixianshi = "正在发送联网开始";
                showxianshi();
                if (flowbass.sjcbz.Contains("38900"))
                {
                    if (zhou == 1)
                    {
                        revert = flowbass.objajlwbass.SendJYXMKSSJ("PBB1", "开始", flowbass.gwjysbbh, flowbass.ipbzdqtongdao.ToString(), flowbass.objcarclass);
                    }
                    else
                    {
                        revert = flowbass.objajlwbass.SendJYXMKSSJ("PBB2", "开始", flowbass.gwjysbbh, flowbass.ipbzdhtongdao.ToString(), flowbass.objcarclass);
                    }
                }
                else
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ(jcxm, "开始", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                }
                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                }
            }
            flowbass.LedWrite("5-10km/h", zhou.ToString()+"轴开始检测", 1);
            sxinxixianshi = "5-10km/h" + zhou.ToString() + "轴开始检测";
            showxianshi();
            if (zhou == 2)
            {
                flowbass.sendpiczj("9999", flowbass.ibrtongdao.ToString(), "zdgw", "zdgw");
            }
            //#region
            #region 车子开过红外或重量大于设置的开始重量
            for (; ; )
            {
                
                    if (m_mainform.WaitEventZT(iFLHWH, bhongwaiqf[iFLHWH], ihongwaidwsj[iFLHWH]))
                    {
                        hongwai = true;
                        break;
                    }
                    //需要加上经过红外进入流程
                    dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo2]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
                    dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo2]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);

                    dAIzhidongzuo2 = m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo2]) - m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo2]);
                    dAIzhidongyuo2 = m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo2]) - m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo2]);

                    dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
                    dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);

                    dAIzhidongzuo2 = Math.Round(dAIzhidongzuo2);
                    dAIzhidongyuo2 = Math.Round(dAIzhidongyuo2);
                
               

                //后板轮重或者后板制动大于设置的开始重量，退出循环，进入流程
                if ((((dAIlunzhongyuo2 + dAIlunzhongzuo2) > m_StartWei) || ((dAIzhidongzuo2 + dAIzhidongyuo2) > m_StartWei))&&hongwai)
                {
                    flowbass.LedWrite("请踩刹车", "", 1);
                    break;
                }
                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }
                Thread.Sleep(5);
            }
            #endregion
            DateTime dtimestart = DateTime.Now;

            #region 制动检测流程（包括动态轮重），先取采样值，再计算出计算值

            List<double> listlzzlscyz = new List<double>();
            List<double> listlzylscyz = new List<double>();
            List<double> listzdzlscyz = new List<double>();
            List<double> listzdylscyz = new List<double>();

            flowbass.LedWrite("正在检测", "", 1);
            sxinxixianshi = "正在检测";
            showxianshi();
            while (true)
            {
                Debug.WriteLine(string.Format("采样值时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "1"));
                listlzzlscyz.Add(m_mainform.DAC.fAIData[iAIlunzhongzuo2]);
                listlzylscyz.Add(m_mainform.DAC.fAIData[iAIlunzhongyuo2]);
                listzdzlscyz.Add(m_mainform.DAC.fAIData[iAIzhidongzuo2]);
                listzdylscyz.Add(m_mainform.DAC.fAIData[iAIzhidongyuo2]);

                //保证时间
                if (m_mainform.DateDiff(DateTime.Now, dtimestart) > (m_dLimitTime))// 检测5秒
                {
                    break;
                }
                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }
                Thread.Sleep(10);
                Debug.WriteLine(string.Format("采样值时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "2"));
            }

            Debug.WriteLine(string.Format("采样值时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "3"));

            for (int i = 0; i < listlzzlscyz.Count; i++)
            {
                dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左", (float)listlzzlscyz[i]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
                dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右", (float)listlzylscyz[i]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);
                dAIzhidongzuo2 = m_mainform.DAC.getjsz("平板后制动左", (float)listzdzlscyz[i]) - m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo2]);
                dAIzhidongyuo2 = m_mainform.DAC.getjsz("平板后制动右", (float)listzdylscyz[i]) - m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo2]);


                if (dAIlunzhongzuo2 < 0)
                {
                    dAIlunzhongzuo2 = m_mainform.getRandom(1, 5);//
                }
                if (dAIlunzhongyuo2 < 0)
                {
                    dAIlunzhongyuo2 = m_mainform.getRandom(1, 5);//
                }
                if (dAIzhidongzuo2 < 0)
                {
                    dAIzhidongzuo2 = m_mainform.getRandom(1, 5);//
                }
                if (dAIzhidongyuo2 < 0)
                {
                    dAIzhidongyuo2 = m_mainform.getRandom(1, 5);//
                }

                if (i>0&&(dAIzhidongzuo2 >= 5 || dAIzhidongyuo2 >= 5))
                {
                    if (zhou == 1)
                    {
                        if (Math.Round(dAIzhidongzuo2) == listzdz1[listlzz1.Count - 1] || Math.Round(dAIzhidongyuo2) == listzdy1[listzdy1.Count - 1])
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (Math.Round(dAIzhidongzuo2) == listzdz2[listlzz2.Count - 1] || Math.Round(dAIzhidongyuo2) == listzdy2[listzdy2.Count - 1])
                        {
                            continue;
                        }
                    }
                }

                //Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "4"));
                dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
                dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);
                dAIzhidongzuo2 = Math.Round(dAIzhidongzuo2);
                dAIzhidongyuo2 = Math.Round(dAIzhidongyuo2);

                //Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "5"));
                if (zhou == 1)
                {
                    listlzz1.Add(dAIlunzhongzuo2);
                    listlzy1.Add(dAIlunzhongyuo2);
                    listzdz1.Add(dAIzhidongzuo2);
                    listzdy1.Add(dAIzhidongyuo2);
                }
                else
                {
                    listlzz2.Add(dAIlunzhongzuo2);
                    listlzy2.Add(dAIlunzhongyuo2);
                    listzdz2.Add(dAIzhidongzuo2);
                    listzdy2.Add(dAIzhidongyuo2);
                }

                //Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "6"));

                xsdlunzhongzuo2 = dAIlunzhongzuo2;
                xsdlunzhongyuo2 = dAIlunzhongyuo2;
                xsdzhidongzuo2 = dAIzhidongzuo2;
                xsdzhidongyuo2 = dAIzhidongyuo2;

                //Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "7"));
                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }

                //Thread.Sleep(10);
                //Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "8"));
                //保证时间
                //if (m_mainform.DateDiff(DateTime.Now, dtimestart) > (m_dLimitTime))// 检测5秒
                //{
                //    break;
                //}
            }
            #endregion
            #region 制动检测流程（包括动态轮重）
            //while (true)
            //{
            //    Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "1"));
            //    flowbass.LedWrite("正在检测", "", 1);
            //    Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "2"));
            //    dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo2]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
            //    dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo2]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);
            //    dAIzhidongzuo2 = m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo2]) - m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo2]);
            //    dAIzhidongyuo2 = m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo2]) - m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo2]);

            //    Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "3"));
            //    if (dAIlunzhongzuo2 < 0)
            //    {
            //        dAIlunzhongzuo2 = m_mainform.getRandom(1, 5);//
            //    }
            //    if (dAIlunzhongyuo2 < 0)
            //    {
            //        dAIlunzhongyuo2 = m_mainform.getRandom(1, 5);//
            //    }
            //    if (dAIzhidongzuo2 < 0)
            //    {
            //        dAIzhidongzuo2 = m_mainform.getRandom(1, 5);//
            //    }
            //    if (dAIzhidongyuo2 < 0)
            //    {
            //        dAIzhidongyuo2 = m_mainform.getRandom(1, 5);//
            //    }

            //    Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "4"));
            //    dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
            //    dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);
            //    dAIzhidongzuo2 = Math.Round(dAIzhidongzuo2);
            //    dAIzhidongyuo2 = Math.Round(dAIzhidongyuo2);

            //    Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "5"));
            //    if (zhou == 1)
            //    {
            //        listlzz1.Add(dAIlunzhongzuo2);
            //        listlzy1.Add(dAIlunzhongyuo2);
            //        listzdz1.Add(dAIzhidongzuo2);
            //        listzdy1.Add(dAIzhidongyuo2);
            //    }
            //    else
            //    {
            //        listlzz2.Add(dAIlunzhongzuo2);
            //        listlzy2.Add(dAIlunzhongyuo2);
            //        listzdz2.Add(dAIzhidongzuo2);
            //        listzdy2.Add(dAIzhidongyuo2);
            //    }

            //    Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "6"));
                
            //    xsdlunzhongzuo2 = dAIlunzhongzuo2;
            //    xsdlunzhongyuo2 = dAIlunzhongyuo2;
            //    xsdzhidongzuo2 = dAIzhidongzuo2;
            //    xsdzhidongyuo2 = dAIzhidongyuo2;

            //    Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "7"));
            //    if (flowbass.IsCancle())
            //    {
            //        flowbass.LedWrite("检测取消", "", 1);
            //        return;
            //    }

            //    Thread.Sleep(10);
            //    Debug.WriteLine(string.Format("时间：{0}节点：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "8"));
            //    //保证时间
            //    if (m_mainform.DateDiff(DateTime.Now, dtimestart) > (m_dLimitTime))// 检测5秒
            //    {
            //        break;
            //    }
            //}
            #endregion

            showsjhou();

            if (flowbass.sjcbz.Contains("38900"))
            {
                if (zhou < 2)
                {
                    flowbass.objajlwbass.sendpic(flowbass.ipbzdqtongdao.ToString(), pic_br38900[zhou - 1], flowbass.objcarclass);//图片抓拍
                    //flowbass.objajlwbass.sendpic(flowbass.ipbzdqtongdao.ToString(), pic_we38900[zhou - 1], flowbass.objcarclass);//图片抓拍
                }
                else
                {
                    flowbass.objajlwbass.sendpic(flowbass.ipbzdhtongdao.ToString(), pic_br38900[zhou - 1], flowbass.objcarclass);//图片抓拍
                    //flowbass.objajlwbass.sendpic(flowbass.ipbzdhtongdao.ToString(), pic_we38900[zhou - 1], flowbass.objcarclass);//图片抓拍
                }
            }
            else
            {
                if (ssxt)
                {
                    if (zhou < 2)
                    {
                        flowbass.objajlwbass.sendpic(flowbass.ibrtongdao2.ToString(), pic_br[zhou - 1], flowbass.objcarclass);//图片抓拍
                    }
                    else
                    {
                        flowbass.objajlwbass.sendpic(flowbass.ibrtongdao.ToString(), pic_br[zhou - 1], flowbass.objcarclass);//图片抓拍
                    }
                }
                else
                {
                    flowbass.objajlwbass.sendpic(flowbass.ibrtongdao.ToString(), pic_br[zhou - 1], flowbass.objcarclass);//图片抓拍
                }
            }
            
            flowbass.LedWrite("检测完成", "", 1);
            sxinxixianshi = "制动检测完成";
            showxianshi();
            Thread.Sleep(xssj);
            #region 曲线平滑处理
            //for (int k = 0; k < 2; k++)
            //{
            //    if (zhou == 1)
            //    {
            //        for (int i = 0; i < listlzz1.Count - 1; i++)
            //        {
            //            listlzz1[i] = Math.Round((listlzz1[i] + listlzz1[i + 1]) / 2);
            //            listlzy1[i] = Math.Round((listlzy1[i] + listlzy1[i + 1]) / 2);
            //            listzdz1[i] = Math.Round((listzdz1[i] + listzdz1[i + 1]) / 2);
            //            listzdy1[i] = Math.Round((listzdy1[i] + listzdy1[i + 1]) / 2);
            //        }
            //    }

            //    if (zhou == 2)
            //    {
            //        for (int i = 0; i < listlzz2.Count - 1; i++)
            //        {
            //            listlzz2[i] = Math.Round((listlzz2[i] + listlzz2[i + 1]) / 2);
            //            listlzy2[i] = Math.Round((listlzy2[i] + listlzy2[i + 1]) / 2);

            //            listzdz2[i] = Math.Round((listzdz2[i] + listzdz2[i + 1]) / 2);
            //            listzdy2[i] = Math.Round((listzdy2[i] + listzdy2[i + 1]) / 2);
            //        }
            //    }
            //}




            //string szdqxsj1 = "10@";
            //string szdqxsj2 = "10@";
            if (zhou == 1)
            {
                szdqxsj[0] = "10@";
            }
            else
            {
                szdqxsj[1] = "10@";
            }
            if (zhou == 1)
            {
                for (int icount = 0; icount < listlzz1.Count; icount++)
                {
                    string slsqx = "";
                    {
                        slsqx = string.Format("{0}#{1}$", listzdz1[icount], listzdy1[icount]);
                        szdqxsj[0] += slsqx;
                    }

                }
            }
            else
            {
                string slsqx = "";
                for (int icount = 0; icount < listlzz2.Count; icount++)
                {
                    slsqx = string.Format("{0}#{1}$", listzdz2[icount], listzdy2[icount]);
                    szdqxsj[1] += slsqx;
                }
            }

            #endregion

            double fLMax1 = 0;
            double fRMax1 = 0;
            double fLMax2 = 0;
            double fRMax2 = 0;

            double fLMaxWE1 = 0;
            double fRMaxWE1 = 0;
            double fLMaxWE2 = 0;
            double fRMaxWE2 = 0;
            #region 找出最大制动力点
            //找出最大制动力点
            if (zhou == 1)
            {
                for (int i = 0; i < listlzz1.Count; i++)
                {
                    if (listzdz1[i] > fLMax1)
                    {
                        fLMaxWE1 = listlzz1[i];
                        fLMax1 = listzdz1[i];
                        iMaxBrLPoint = i;
                    }
                    if (listzdy1[i] > fRMax1)
                    {
                        fRMaxWE1 = listlzy1[i];
                        fRMax1 = listzdy1[i];
                        iMaxBrRPoint = i;
                    }
                }
            }
            else
            {
                for (int i = 0; i < listlzz2.Count; i++)
                {
                    if (listzdz2[i] > fLMax2)
                    {
                        fLMaxWE2 = listlzz2[i];
                        fLMax2 = listzdz2[i];
                        iMaxBrLPoint2 = i;
                    }
                    if (listzdy2[i] > fRMax2)
                    {
                        fRMaxWE2 = listlzy2[i];
                        fRMax2 = listzdy2[i];
                        iMaxBrRPoint2 = i;
                    }
                }
            }

            if (zhou == 1)
            {
                if (iMaxBrLPoint > iMaxBrRPoint)
                {
                    iMinBrLPoint = iMaxBrRPoint;//第一个取值点
                    iMaxBrRPoint = iMaxBrLPoint;
                }
                else
                {
                    iMinBrLPoint = iMaxBrLPoint;//第一个取值点
                }
            }
            else
            {
                if (iMaxBrLPoint2 > iMaxBrRPoint2)
                {
                    iMinBrLPoint2 = iMaxBrRPoint2;//第一个取值点
                    iMaxBrRPoint2 = iMaxBrLPoint2;
                }
                else
                {
                    iMinBrLPoint2 = iMaxBrLPoint2;//第一个取值点
                }
            }

            if (zhou == 1)
            {
                xsdlunzhongzuo2 = fLMaxWE1;
                xsdlunzhongyuo2 = fRMaxWE1;
                xsdzhidongzuo2 = fLMax1;
                xsdzhidongyuo2 = fRMax1;
            }
            else
            {
                xsdlunzhongzuo2 = fLMaxWE2;
                xsdlunzhongyuo2 = fRMaxWE2;
                xsdzhidongzuo2 = fLMax2;
                xsdzhidongyuo2 = fRMax2;
            }
            showsjhou();

            if (zhou == 1)
            {
                dzhidongzuo1 = fLMax1;
                dzhidongyuo1 = fRMax1;
                dtdlunzhongzuo1 = fLMaxWE1;
                dtdlunzhongyuo1 = fRMaxWE1;

                //赋值制动力
            flowbass.VAX_VBRAKEL[0] = (float)dzhidongzuo1;
            flowbass.VAX_VBRAKER[0] = (float)dzhidongyuo1;
            }
            else
            {
                dzhidongzuo2 = fLMax2;
                dzhidongyuo2 = fRMax2;
                dtdlunzhongzuo2 = fLMaxWE2;
                dtdlunzhongyuo2 = fRMaxWE2;
                flowbass.VAX_VBRAKEL[1] = (float)dzhidongzuo2;
                flowbass.VAX_VBRAKER[1] = (float)dzhidongyuo2;
            }
            #endregion


            #region 找最大不平衡力
            if (zhou == 1)
            {
                uMaxSum = (int)Math.Abs(listzdz1[iMinBrLPoint] + listzdy1[iMinBrLPoint]);//第一取值点和
                uMinSum = (int)Math.Abs(listzdz1[iMinBrLPoint] - listzdy1[iMinBrLPoint]);//第一取值点和
                for (int i = 0; i <= iMaxBrRPoint; i++)
                {
                    if (i <= iMinBrLPoint)
                    {
                        if (uMaxSub < Math.Abs(listzdz1[i] - listzdy1[i]))
                        {
                            //m_mainform.baocunriji("1制动曲线", string.Format(@"左：{0}；右：{1},差：{2}", listzdz1[i], listzdy1[i], (int)Math.Abs(listzdz1[i] - listzdy1[i])));
                            uMaxSub = (int)Math.Abs(listzdz1[i] - listzdy1[i]);
                            uBrakePointL = (int)listzdz1[i];
                            uBrakePointR = (int)listzdy1[i];
                        }
                    }
                    else
                    {

                        if (i < iMinBrLPoint + 2 && uMinSum > Math.Abs(listzdz1[i] - listzdy1[i]))//第一最大点，过程差校验，如果后面比它大继续下去
                        {
                            break;
                        }
                        else
                        {
                            if (uMaxSub < Math.Abs(listzdz1[i] - listzdy1[i]) && uMaxSum < Math.Abs(listzdz1[i] + listzdy1[i]))
                            {
                                //m_mainform.baocunriji("1制动曲线", string.Format(@"左：{0}；右：{1},差：{2}", listzdz1[i], listzdy1[i], (int)Math.Abs(listzdz1[i] - listzdy1[i])));
                                uMaxSum = (int)Math.Abs(listzdz1[i] + listzdy1[i]);
                                uMaxSub = (int)Math.Abs(listzdz1[i] - listzdy1[i]);
                                uBrakePointL = (int)listzdz1[i];
                                uBrakePointR = (int)listzdy1[i];
                            }
                        }
                    }
                } 
            }
            else
            {
                uMaxSum = (int)Math.Abs(listzdz2[iMinBrLPoint2] + listzdy2[iMinBrLPoint2]);//第一取值点和
                uMinSum = (int)Math.Abs(listzdz2[iMinBrLPoint2] - listzdy2[iMinBrLPoint2]);//第一取值点和
                for (int i = 0; i <= iMaxBrRPoint2; i++)
                {
                    if (i <= iMinBrLPoint2)
                    {
                        if (uMaxSub < Math.Abs(listzdz2[i] - listzdy2[i]))
                        {
                            //m_mainform.baocunriji("2制动曲线", string.Format(@"左：{0}；右：{1},差：{2}", listzdz2[i], listzdy2[i], (int)Math.Abs(listzdz2[i] - listzdy2[i])));
                            uMaxSub = (int)Math.Abs(listzdz2[i] - listzdy2[i]);
                            uBrakePointL = (int)listzdz2[i];
                            uBrakePointR = (int)listzdy2[i];
                        }
                    }
                    else
                    {
                        if (i < iMinBrLPoint2 + 2 && uMinSum > Math.Abs(listzdz2[i] - listzdy2[i]))//第一最大点，过程差校验，如果后面比它大继续下去
                        {
                            break;
                        }
                        else
                        {
                            if (uMaxSub < Math.Abs(listzdz2[i] - listzdy2[i]) && uMaxSum < Math.Abs(listzdz2[i] + listzdy2[i]))
                            {
                                //m_mainform.baocunriji("2制动曲线", string.Format(@"左：{0}；右：{1},差：{2}", listzdz2[i], listzdy2[i], (int)Math.Abs(listzdz2[i] - listzdy2[i])));
                                uMaxSum = (int)Math.Abs(listzdz2[i] + listzdy2[i]);
                                uMaxSub = (int)Math.Abs(listzdz2[i] - listzdy2[i]);
                                uBrakePointL = (int)listzdz2[i];
                                uBrakePointR = (int)listzdy2[i];
                            }
                        }
                    }

                }
            }
            if (zhou == 1)
            {
                dzhidongchazuo1 = uBrakePointL;
                dzhidongchayuo1 = uBrakePointR;
            }
            else
            {
                dzhidongchazuo2 = uBrakePointL;
                dzhidongchayou2 = uBrakePointR;
            }
            #endregion

            #region 检测轮重
            ///////////////检测轴重
            if (flowbass.bweight)
            {
                //if(bDetWei1 || bDetWei2 || bDetSu1 || bDetSu2)		
                {
                    dtimestart = DateTime.Now;
                    flowbass.LedWrite("开始检测轮重", "", 1);
                    sxinxixianshi = "开始检测轮重";
                    showxianshi();
                    for (; ; )
                    {
                        //dAIlunzhongzuo1 = m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo1]) - m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo1]);
                        //dAIlunzhongyuo1 = m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo1]) - m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo1]);

                        dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo2]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
                        dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo2]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);
                        //dAIlunzhongzuo1 = Math.Round(dAIlunzhongzuo1);
                        //dAIlunzhongyuo1 = Math.Round(dAIlunzhongyuo1);

                        dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
                        dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);

                        xsdlunzhongzuo2 = dAIlunzhongzuo2;
                        xsdlunzhongyuo2 = dAIlunzhongyuo2;
                        showsjhou();
                        if (flowbass.IsCancle())
                        {
                            flowbass.LedWrite("检测取消", "", 1);
                            return;
                        }
                        //保证时间
                        if (m_mainform.DateDiff(DateTime.Now, dtimestart) > (m_dLimitTime))// 检测5秒
                        {
                            break;
                        }
                        Thread.Sleep(100);

                    }


                    xsdlunzhongzuo2 = dAIlunzhongzuo2;
                    xsdlunzhongyuo2 = dAIlunzhongyuo2;
                    showsjhou();
                    if (zhou == 1)
                    {
                        dlunzhongzuo1 = dAIlunzhongzuo2;
                        dlunzhongyuo1 = dAIlunzhongyuo2;
                        flowbass.VAX_VWGHTLSP[0] = (float)dlunzhongzuo1;
                        flowbass.VAX_VWGHTRSP[0] = (float)dlunzhongyuo1;
                    }
                    else
                    {
                        dlunzhongzuo2 = dAIlunzhongzuo2;
                        dlunzhongyuo2 = dAIlunzhongyuo2;
                        flowbass.VAX_VWGHTLSP[1] = (float)dlunzhongzuo2;
                        flowbass.VAX_VWGHTRSP[1] = (float)dlunzhongyuo2;
                    }
                    flowbass.LedWrite("轮重检测结束", "", 1);
                    sxinxixianshi = "轮重检测结束";
                    showxianshi();
                    Thread.Sleep(xssj);
                }
            }
            #endregion


        }


        public void DetectBrakeSHOUSHA()
        {
            flowbass.objcarclass.tongdao1 = flowbass.ipbzdqtongdao.ToString();
            flowbass.objcarclass.tongdao2 = flowbass.ipbzdhtongdao.ToString();
            flowbass.LedWrite("准备检测手刹", "", 1);
            string []  pic_brzc = new string[1] { "0351" };
            List<double> listzdzSS = new List<double>();
            List<double> listzdySS = new List<double>();

            sxinxixianshi = "准备检测手刹";
            showxianshi();
            bool chufahongwai = false;
            //#region
            if (flowbass.bnj)//综检不传
            {
                if (flowbass.sjcbz.Contains("38900"))
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("B0Q", "开始", flowbass.gwjysbbh, flowbass.ipbzdqtongdao.ToString(), flowbass.objcarclass);
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("B0H", "开始", flowbass.gwjysbbh, flowbass.ipbzdhtongdao.ToString(), flowbass.objcarclass);
                }
                else
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("B0", "开始", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                }
                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                }

            }
            #region 车子开过红外或重量大于设置的开始重量
            for (; ; )
            {

                if (m_mainform.WaitEventZT(iFLHWQ, bhongwaiqf[iFLHWQ], ihongwaidwsj[iFLHWQ]))
                {
                    chufahongwai = true;
                   break;
                   
                }

                dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo2]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
                dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo2]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);

                dAIzhidongzuo2 = m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo2]) - m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo2]);
                dAIzhidongyuo2 = m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo2]) - m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo2]);

                dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
                dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);

                dAIzhidongzuo2 = Math.Round(dAIzhidongzuo2);
                dAIzhidongyuo2 = Math.Round(dAIzhidongyuo2);

                //后板轮重或者后板制动大于设置的开始重量，退出循环，进入流程
                if ((((dAIlunzhongyuo2 + dAIlunzhongzuo2) > m_StartWei) || ((dAIzhidongzuo2 + dAIzhidongyuo2) > m_StartWei))&&chufahongwai)
                {
                    break;
                }
                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }
                Thread.Sleep(50);
            }
            #endregion
           
            flowbass.LedWrite("驻车开始", "", 1);
            DateTime dtimestart = DateTime.Now;
            #region 手刹检测流程
            while (true)
            {
                flowbass.LedWrite("请拉手刹", "", 1);
                dAIzhidongzuo1 = m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo1]) - m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo1]);
                dAIzhidongyuo1 = m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo1]) - m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo1]);

                dAIzhidongzuo1 = Math.Round(dAIzhidongzuo1);
                dAIzhidongyuo1 = Math.Round(dAIzhidongyuo1);

                listzdzSS.Add(dAIzhidongzuo1);
                listzdySS.Add(dAIzhidongyuo1);

                xsdzhidongzuo1 = dAIzhidongzuo1;
                xsdzhidongyuo1 = dAIzhidongyuo1;
                //showsj();

                if (flowbass.IsCancle())
                {
                    flowbass.LedWrite("检测取消", "", 1);
                    return;
                }

                //保证时间
                if (m_mainform.DateDiff(DateTime.Now, dtimestart) > (m_dLimitTime))// 检测5秒
                {
                    break;
                }
                Thread.Sleep(10);
            }
            #endregion
            flowbass.LedWrite("手刹检测完成", "请松手刹", 1);
            sxinxixianshi = "手刹检测完成,请松手刹";
            showxianshi();
            Thread.Sleep(xssj);

            if (flowbass.sjcbz.Contains("38900"))
            {
                flowbass.objajlwbass.sendpic(flowbass.ipbzdqtongdao.ToString(), "A316", flowbass.objcarclass);//图片抓拍
                flowbass.objajlwbass.sendpic(flowbass.ipbzdhtongdao.ToString(), "A317", flowbass.objcarclass);//图片抓拍
            }
            else
            {
                flowbass.objajlwbass.sendpic(flowbass.ibrtongdao.ToString(), pic_brzc[0], flowbass.objcarclass);//图片抓拍
            }
            #region 找出最大手刹力点
            double fLMax1 = 0;
            double fRMax1 = 0;
            //找出最大手刹力点
            for (int i = 0; i < listzdzSS.Count; i++)
            {
                if (listzdzSS[i] > fLMax1)
                {
                    fLMax1 = listzdzSS[i];
                }
                if (listzdySS[i] > fRMax1)
                {
                    fRMax1 = listzdySS[i];
                }
            }

            xsdzhidongzuo1 = fLMax1;
            xsdzhidongyuo1 = fRMax1;
            showsj();
            dshoushazuo = fLMax1;
            dshoushayuo = fRMax1;
            #endregion


           

            //double dzhengchelz = (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) > 0 ? (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) : 1;
            double dzhengchelz=(double)(flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0] + flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]);
            double fHBrakeF = Math.Round((100 * (dshoushazuo + dshoushayuo) / (dzhengchelz * 0.98)), 1);
            //fHBrakeF = Math.Round(fHBrakeF, 1);

         

            bool bGood = true;
            if (fHBrakeF < flowbass.STD_HALT)
            {
                bGood = false;
            }

            if (!bGood)
            {
                flowbass.getbuhge(flowbass.sDetectID, "B0");
            }
            else
            {
                flowbass.sethege(flowbass.sDetectID, "B0");
            }


            flowbass.AddData(flowbass.sDetectID, "DET_SSJL", "Detects_SJB", bGood ? 1 : 2);

            //保存数据
            flowbass.AddData_Check(flowbass.sDetectID, "DET_HALTZ2", "Detects_SJB", dshoushazuo.ToString("0"));
            flowbass.AddData_Check(flowbass.sDetectID, "DET_HALTY2", "Detects_SJB", dshoushayuo.ToString("0"));
            flowbass.AddData_Check(flowbass.sDetectID, "DET_HALTH2", "Detects_SJB", (dshoushazuo + dshoushayuo).ToString("0"));


            //保存数据
            flowbass.AddData_Check(flowbass.sDetectID, "DET_HALTZH", "Detects_SJB", dshoushazuo.ToString("0"));
            flowbass.AddData_Check(flowbass.sDetectID, "DET_HALTYH", "Detects_SJB", dshoushayuo.ToString("0"));
            flowbass.AddData_Check(flowbass.sDetectID, "DET_HALTH", "Detects_SJB", (dshoushazuo + dshoushayuo).ToString("0"));
            flowbass.AddData_Check(flowbass.sDetectID, "DET_HALTF", "Detects_SJB", fHBrakeF.ToString("0.0"));
            flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTHSS", "Detects_SJB", dzhengchelz.ToString("0"));


            string jielun = "";
            jielun = string.Format(@"{0},{1},{2},{3}",
                                    string.Format("驻车制动率(%)"),
                                    string.Format("{0}", fHBrakeF),
                                    string.Format("≥{0}", flowbass.STD_HALT),
                                    string.Format("{0}", bGood ? "合格" : "不合格")
                                    );
            flowbass.AddData(flowbass.sDetectID, "PD_ZHUCHE", "PD_AJ", jielun);
            if (flowbass.bzj)
            {
                flowbass.AddData(flowbass.sDetectID, "PD_ZHUCHE", "PD_ZJ", jielun);
            }



            string sdp = string.Format("左{0}  右{1}", dshoushazuo, dshoushayuo);
            flowbass.LedWrite("手刹制动力", sdp, 1);
            sxinxixianshi = string.Format("手刹制动力:左{0}右{1}", dshoushazuo, dshoushayuo);
            showxianshi();
            Thread.Sleep(xssj);
            flowbass.LedWrite(string.Format("手刹制动率:{0}", fHBrakeF), bGood ? "合格" : "不合格", 1);
            sxinxixianshi = string.Format("手刹制动率:{0},{1}", fHBrakeF, bGood ? "合格" : "不合格");
            showxianshi();
            Thread.Sleep(xssj);


           
            string yzzczdl = "";
            string ezzczdl = (dshoushazuo + dshoushayuo).ToString();
            string sanzzczdl ="";
            string sizzczdl = "";
            string wzzczdl = "";
            string zczczdl = (dshoushazuo + dshoushayuo).ToString();
            string tczzdl = (dshoushazuo).ToString();
            string tcyzdl = (dshoushayuo).ToString();
            double tczdl =  fHBrakeF;
            if (yzzczdl.Trim() == "0")
            {
                yzzczdl = "";
            }
            if (ezzczdl.Trim() == "0")
            {
                ezzczdl = "";
            }
            if (sanzzczdl.Trim() == "0")
            {
                sanzzczdl = "";
            }
            if (sizzczdl.Trim() == "0")
            {
                sizzczdl = "";
            }
            if (wzzczdl.Trim() == "0")
            {
                wzzczdl = "";
            }



            model.安检联网.modelB0 objmodellw = new model.安检联网.modelB0();
            objmodellw.yzzczdl = yzzczdl;
            objmodellw.ezzczdl = ezzczdl;
            objmodellw.sanzzczdl = sanzzczdl;
            objmodellw.sizzczdl = sizzczdl;
            objmodellw.wzzczdl = wzzczdl;
            objmodellw.zczczdl = zczczdl;
            objmodellw.tczzdl = tczzdl;
            objmodellw.tcyzdl = tcyzdl;
            objmodellw.tczdl = tczdl.ToString();
            objmodellw.tczdpd = bGood ? "1" : "2";
            if (flowbass.bnj)//综检不传
            {
                revert=  flowbass.objajlwbass.write(flowbass.objcarclass, objmodellw);

                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                }
                Thread.Sleep(1000);
                if (flowbass.sjcbz.Contains("38900"))
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("B0Q", "结束", flowbass.gwjysbbh, flowbass.ipbzdqtongdao.ToString(), flowbass.objcarclass);
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("B0H", "结束", flowbass.gwjysbbh, flowbass.ipbzdhtongdao.ToString(), flowbass.objcarclass);
                }
                else
                {
                    revert = flowbass.objajlwbass.SendJYXMKSSJ("B0", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                }

                if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                {
                    flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                }
            }
            flowbass.getProcessfinish(flowbass.sDetectID, "B0");

        }
        //计算制动率与写入数据库
        public void JudgeTotalResult(int iml)
        {
            //iml 0:四轮同检 1：前轴 2：后轴 3：只计算整车制动



            #region 计算制动力
            double dBrakeF1 = 0, BrakeDBF1= 0, dBrakeDB1 = 0;//制动率 不平衡率 制动差
            double dBrakeF2 = 0, BrakeDBF2 = 0, dBrakeDB2 = 0;//制动率 不平衡率 制动差
            double dTotalWei = 0;
            if (iml == 1 || iml == 0)
            {
                if ((flowbass.sCllx.Contains("小型") || flowbass.sCllx.Contains("微型")) && (flowbass.sCllx.Contains("轿") || flowbass.sCllx.Contains("面包") || flowbass.sCllx.Contains("客")) || flowbass.sCllx.Contains("货") && flowbass.iCLZZL < 3500)
                {
                    dBrakeF1 = Math.Round(100 * (dzhidongzuo1 + dzhidongyuo1) / ((dtdlunzhongzuo1 + dtdlunzhongyuo1) > 1 ? (dtdlunzhongzuo1 + dtdlunzhongyuo1) * 0.98 : 1), 1);
                }
                else
                {
                    //dBrakeF1 = Math.Round(100 * (dzhidongzuo1 + dzhidongyuo1) / ((dlunzhongzuo1 + dlunzhongyuo1) > 1 ? (dlunzhongzuo1 + dlunzhongyuo1) * 0.98 : 1), 1);
                    dBrakeF1 = Math.Round(100 * (dzhidongzuo1 + dzhidongyuo1) / ((flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0]) > 1 ? (flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0]) * 0.98 : 1), 1);
                }
                dBrakeDB1=Math.Abs(dzhidongchazuo1 - dzhidongchayuo1);
                BrakeDBF1 = Math.Round(100 * (dBrakeDB1) / ((dzhidongzuo1 > dzhidongyuo1) ? dzhidongzuo1 : dzhidongyuo1), 1);
            }
            if (iml == 2 || iml == 0)
            {

                if ((flowbass.sCllx.Contains("小型") || flowbass.sCllx.Contains("微型")) && (flowbass.sCllx.Contains("轿") || flowbass.sCllx.Contains("面包") || flowbass.sCllx.Contains("客")) || flowbass.sCllx.Contains("货") && flowbass.iCLZZL < 3500)
                {
                    dBrakeF2 = Math.Round(100 * (dzhidongzuo2 + dzhidongyuo2) / ((dtdlunzhongzuo2 + dtdlunzhongyuo2) > 1 ? (dtdlunzhongzuo2 + dtdlunzhongyuo2) * 0.98 : 1), 1);
                    dBrakeDB2 = Math.Abs(dzhidongchazuo2 - dzhidongchayou2);
                    if (dBrakeF2 < 60)
                    {
                        BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((dlunzhongzuo2 + dlunzhongyuo2) > 1 ? (dlunzhongzuo2 + dlunzhongyuo2) * 0.98 : 1), 1);
                        //BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) > 1 ? (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) * 0.98 : 1), 1);
                    }
                    else
                    {
                        
                        BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((dzhidongzuo2 > dzhidongyuo2) ? dzhidongzuo2 : dzhidongyuo2), 1);
                    }
                }
                else
                {
                    //dBrakeF2 = Math.Round(100 * (dzhidongzuo2 + dzhidongyuo2) / ((dlunzhongzuo2 + dlunzhongyuo2) > 1 ? (dlunzhongzuo2 + dlunzhongyuo2) * 0.98 : 1), 1);
                    dBrakeF2 = Math.Round(100 * (dzhidongzuo2 + dzhidongyuo2) / ((flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) > 1 ? (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) * 0.98 : 1), 1);
                    dBrakeDB2 = Math.Abs(dzhidongchazuo2 - dzhidongchayou2);
                    if (dBrakeF2 < 60)
                    {
                        //BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((dlunzhongzuo2 + dlunzhongyuo2) > 1 ? (dlunzhongzuo2 + dlunzhongyuo2) * 0.98 : 1), 1);
                        BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) > 1 ? (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) * 0.98 : 1), 1);
                    }
                    else
                    {
                        BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((dzhidongzuo2 > dzhidongyuo2) ? dzhidongzuo2 : dzhidongyuo2), 1);
                    }
                }
            }
            if (iml == 3 || iml == 0)
            {
                //double dzhengchezd = dzhidongzuo1 + dzhidongyuo1 + dzhidongzuo2 + dzhidongyuo2;
                //double dzhengchelz = (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) > 0 ? (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) : 1;
                double dzhengchezd = (double)(flowbass.VAX_VBRAKEL[0] + flowbass.VAX_VBRAKER[0] + flowbass.VAX_VBRAKEL[1] + flowbass.VAX_VBRAKER[1]);
                double dzhengchelz = (double)(flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0] + flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]);
                dTotalWei = (double)(100 * dzhengchezd / (dzhengchelz * 0.98));
                dTotalWei = Math.Round(dTotalWei, 1);
                //dTotalWei = Math.Round(100 * (dzhengchezd) / ((dzhengchelz) * 0.98), 1);
            }
            #endregion
            #region 判定制动力与不平衡率是否合格
                bool bBrakeF1 = true;
                bool bBrakeDBF1 = true;
                bool bBrakeF2 = true;
                bool bBrakeDBF2 = true;
                bool bbrakezhengche = true;
                double fzdlxz1 = 0, fbphlxz1 = 0;
                double fzdlxz2 = 0, fbphlxz2 = 0;
            if (iml == 1 || iml == 0)
            {
                //制动率
                if (dBrakeF1 < flowbass.STD_FBRAKE)
                {
                    bBrakeF1 = false;
                }
                //不平衡率
                if (BrakeDBF1> flowbass.STD_FBRAKEDIF)
                {
                    bBrakeDBF1 = false;
                }
                fzdlxz1 = flowbass.STD_FBRAKE;
                fbphlxz1 = flowbass.STD_FBRAKEDIF;

                if (!bBrakeF1 || !bBrakeDBF1)
                {
                    flowbass.getbuhge(flowbass.sDetectID, "B1");
                }
                else
                {
                    flowbass.sethege(flowbass.sDetectID, "B1");
                }


            }
            if (iml == 2 || iml == 0)
            {
                //制动率
                if (dBrakeF2 < flowbass.STD_BRAKE2)
                {
                    bBrakeF2 = false;
                }
                //不平衡率
                if (dBrakeF2 >= 60)
                {
                    if (BrakeDBF2 > flowbass.STD_BBRAKEDIF1)
                    {
                        bBrakeDBF2 = false;
                    }
                    fzdlxz2 = flowbass.STD_BRAKE2;
                    fbphlxz2 = flowbass.STD_BBRAKEDIF1;
                }
                else
                {
                    if (BrakeDBF2 > flowbass.STD_BBRAKEDIF2)
                    {
                        bBrakeDBF2 = false;
                    }
                    fzdlxz2 = flowbass.STD_BRAKE2;
                    fbphlxz2 = flowbass.STD_BBRAKEDIF2;
                }

                if (!bBrakeF2 || !bBrakeDBF2)
                {
                    flowbass.getbuhge(flowbass.sDetectID, "B2");
                }
                else
                {
                    flowbass.sethege(flowbass.sDetectID, "B2");
                }
            }
            if (iml == 3 || iml == 0)
            {
                if (dTotalWei < flowbass.STD_BRAKEF)
                {
                    bbrakezhengche = false;
                }
            }
            #endregion


            #region 灯牌显示
            if (iml == 1 || iml == 0)
            {
                string sdpxss = ""; 
                string sdpxsx = "";

                sdpxss = string.Format("1轴制动力");
                sdpxsx = string.Format("左{0} 右{1}", (int)dzhidongzuo1, (int)dzhidongyuo1);
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                Thread.Sleep(xssj);

                sdpxss =  string.Format("1轴制动率{0}%", dBrakeF1);
                sdpxsx =string.Format("{0}", bBrakeF1 ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + ","+sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);

                sdpxss = string.Format("1轴不平衡差值");
                sdpxsx = string.Format("左{0} 右{1}", (int)dzhidongchazuo1, (int)dzhidongchayuo1);
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                Thread.Sleep(xssj);

                sdpxss = string.Format("1轴不平衡率{0}", BrakeDBF1);
                sdpxsx = string.Format("{0}", bBrakeDBF1 ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);
                sdpxss = string.Format("1轴制动判定");
                sdpxsx = string.Format("{0}", (bBrakeF1 && bBrakeDBF1) ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);
            }
            if (iml == 2 || iml == 0)
            {
                string sdpxss = ""; 
                string sdpxsx = "";

                sdpxss = string.Format("2轴制动力");
                sdpxsx = string.Format("左{0} 右{1}", (int)dzhidongzuo2, (int)dzhidongyuo2);
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                Thread.Sleep(xssj);

                sdpxss =string.Format("2轴制动率{0}", dBrakeF2);
                sdpxsx =string.Format("{0}", bBrakeF2 ? "合格" : "不合格");

                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);

                sdpxss = string.Format("2轴不平衡差值");
                sdpxsx = string.Format("左{0} 右{1}", (int)dzhidongchazuo2, (int)dzhidongchayou2);
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                Thread.Sleep(xssj);

                sdpxss = string.Format("2轴不平衡率{0}%", BrakeDBF2);
                sdpxsx = string.Format("{0}", bBrakeDBF2 ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);
                sdpxss = string.Format("2轴制动判定");
                sdpxsx = string.Format("{0}", (bBrakeF2 && bBrakeDBF2) ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);
            }
            if (iml == 3 || iml == 0)
            {
                string sdps = string.Format("整车制动率{0}%", dTotalWei);
                string sdpx = string.Format("{0}", bbrakezhengche ? "合格" : "不合格");
                flowbass.LedWrite(sdps, sdpx, 1);
                sxinxixianshi = sdps + "," + sdpx;
                showxianshi();
                Thread.Sleep(xssj);
                if (!bbrakezhengche)
                {
                    bool bybhg = false;

                    for (int i = 0; i < flowbass.iVax; i++)
                    {
                        if (flowbass.getfjxm(flowbass.sDetectID, string.Format("B{0}", i + 1)))
                            bybhg = true;
                    }
                    if (!bybhg)
                    {
                        for (int i = 0; i < flowbass.iVax; i++)
                        {
                            flowbass.getbuhge(flowbass.sDetectID, string.Format("B{0}", i + 1));
                        }
                    }
                }
            }
            #endregion

            #region 写入数据库
            if (iml == 1 || iml == 0)
            {
                //制动差
                flowbass.AddData(flowbass.sDetectID, "DET_BRIKEDIFFJL1", "Detects_SJB", bBrakeDBF1 ? 1 : 2);
                //制动和
                flowbass.AddData(flowbass.sDetectID, "DET_BRIKEFJL1", "Detects_SJB", bBrakeF1 ? 1 : 2);
                //轴总评价
                flowbass.AddData(flowbass.sDetectID, "DET_ZZJL1", "Detects_SJB", (bBrakeDBF1 && bBrakeF1) ? 1 : 2);

                flowbass.editData(flowbass.sDetectID, "DET_BRIKEQX1", "Detects_SJB", listzdz1, listzdy1); //  //曲线

                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTZ1", "Detects_SJB", flowbass.VAX_VWGHTLSP[0].ToString("0")); //轴重左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTY1", "Detects_SJB", flowbass.VAX_VWGHTRSP[0].ToString("0")); //轴重右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTH1", "Detects_SJB", (flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0]).ToString("0")); //轴重
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTZDT1", "Detects_SJB", dtdlunzhongzuo1.ToString("0")); //轴重左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTYDT1", "Detects_SJB", dtdlunzhongyuo1.ToString("0")); //轴重右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTHDT1", "Detects_SJB", (dtdlunzhongzuo1 + dtdlunzhongyuo1).ToString("0")); //动态轴荷和
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEL1", "Detects_SJB", dzhidongzuo1.ToString("0")); //制动力左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEY1", "Detects_SJB", dzhidongyuo1.ToString("0")); //制动力右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKE1", "Detects_SJB", (dzhidongzuo1 + dzhidongyuo1).ToString("0")); //制动和
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRIKEF1", "Detects_SJB", dBrakeF1.ToString("0.0")); //制动因数
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFC1", "Detects_SJB", (Math.Abs(dzhidongchazuo1 - dzhidongchayuo1)).ToString("0")); //制动差
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRIKEDIFF1", "Detects_SJB", BrakeDBF1.ToString("0.0")); //制动差因素
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFZ1", "Detects_SJB", dzhidongchazuo1.ToString("0")); //制动差左点
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFY1", "Detects_SJB", dzhidongchayuo1.ToString("0")); //制动差右点


                string jielun = "";
                jielun = string.Format(@"{0},{1},{2},{3}",
                                        string.Format("{0}轴制动率/不平衡率(%)", 1),
                                        string.Format("{0}/{1}", dBrakeF1.ToString("0.0"), BrakeDBF1.ToString("0.0")),
                                        string.Format("≥{0}/≤{1}", fzdlxz1, fbphlxz1),
                                        string.Format("{0}/{1}", bBrakeF1 ? "合格" : "不合格", bBrakeDBF1 ? "合格" : "不合格")
                                        );
                flowbass.AddData(flowbass.sDetectID, "PD_BRIKE1", "PD_AJ", jielun);
                //listzdz1[icount], listzdy1[icount]
            }
            if (iml == 2 || iml == 0)
            {
                //制动差
                flowbass.AddData(flowbass.sDetectID, "DET_BRIKEDIFFJL2", "Detects_SJB", bBrakeDBF2 ? 1 : 2);
                //制动和
                flowbass.AddData(flowbass.sDetectID, "DET_BRIKEFJL2", "Detects_SJB", bBrakeF2 ? 1 : 2);
                //轴总评价
                flowbass.AddData(flowbass.sDetectID, "DET_ZZJL2", "Detects_SJB", (bBrakeDBF2 && bBrakeF2) ? 1 : 2);
                flowbass.editData(flowbass.sDetectID, "DET_BRIKEQX2", "Detects_SJB", listzdz2, listzdy2); //  //曲线
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTZ2", "Detects_SJB", flowbass.VAX_VWGHTLSP[1].ToString("0")); //轴重左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTY2", "Detects_SJB", flowbass.VAX_VWGHTRSP[1].ToString("0")); //轴重右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTH2", "Detects_SJB", (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]).ToString("0")); //轴重
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTZDT2", "Detects_SJB", dtdlunzhongzuo2.ToString("0")); //轴重左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTYDT2", "Detects_SJB", dtdlunzhongyuo2.ToString("0")); //轴重右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTHDT2", "Detects_SJB", (dtdlunzhongzuo2 + dtdlunzhongyuo2).ToString("0")); //动态轴荷和
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEL2", "Detects_SJB", dzhidongzuo2.ToString("0")); //制动力左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEY2", "Detects_SJB", dzhidongyuo2.ToString("0")); //制动力右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKE2", "Detects_SJB", (dzhidongzuo2 + dzhidongyuo2).ToString("0")); //制动和
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRIKEF2", "Detects_SJB", dBrakeF2.ToString("0.0")); //制动因数
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFC2", "Detects_SJB", (Math.Abs(dzhidongchazuo2 - dzhidongchayou2)).ToString("0")); //制动差
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRIKEDIFF2", "Detects_SJB", BrakeDBF2.ToString("0.0")); //制动差因素
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFZ2", "Detects_SJB", dzhidongchazuo2.ToString("0")); //制动差左点
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFY2", "Detects_SJB", dzhidongchayou2.ToString("0")); //制动差右点

                string jielun = "";
                jielun = string.Format(@"{0},{1},{2},{3}",
                                        string.Format("{0}轴制动率/不平衡率(%)", 2),
                                        string.Format("{0}/{1}", dBrakeF2.ToString("0.0"), BrakeDBF2.ToString("0.0")),
                                        string.Format("≥{0}/≤{1}", fzdlxz2, fbphlxz2),
                                        string.Format("{0}/{1}", bBrakeF2 ? "合格" : "不合格", bBrakeDBF2 ? "合格" : "不合格")
                                        );
                flowbass.AddData(flowbass.sDetectID, "PD_BRIKE2", "PD_AJ", jielun);

            }
            if (iml == 3 || iml == 0)
            {
                //double dzhengchezd = dzhidongzuo1 + dzhidongyuo1 + dzhidongzuo2 + dzhidongyuo2;
                //double dzhengchelz = (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) > 0 ? (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) : 1;
                double dzhengchezd = (double)(flowbass.VAX_VBRAKEL[0] + flowbass.VAX_VBRAKER[0] + flowbass.VAX_VBRAKEL[1] + flowbass.VAX_VBRAKER[1]);
                double dzhengchelz = (double)(flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0] + flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]);
                
                flowbass.AddData(flowbass.sDetectID, "DET_ZCJL", "Detects_SJB", bbrakezhengche ? 1 : 2);
                //保存数据
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKE", "Detects_SJB", dzhengchezd.ToString("0"));
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEF", "Detects_SJB", dTotalWei.ToString("0.0"));
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTHZC", "Detects_SJB", dzhengchelz.ToString("0")); //整车重量

                //检测结束
                string jielun = "";
                jielun = string.Format(@"{0},{1},{2},{3}",
                                        string.Format("整车制动率(%)"),
                                        string.Format("{0}", dTotalWei.ToString("0.0")),
                                        string.Format("≥{0}", flowbass.STD_BRAKEF),
                                        string.Format("{0}", bbrakezhengche ? "合格" : "不合格")
                                        );
                flowbass.AddData(flowbass.sDetectID, "PD_zhengche", "PD_AJ", jielun);
                if (flowbass.bzj)
                {
                    flowbass.AddData(flowbass.sDetectID, "PD_zhengche", "PD_ZJ", jielun);
                }

            }
            #endregion


            #region 联网上传
            if (iml == 1 || iml == 0)
            {
                //安检数据检测数据上传
                model.安检联网.modelB objmodellw = new model.安检联网.modelB();
                objmodellw.zlz = string.Format(@"{0}", flowbass.VAX_VWGHTLSP[0].ToString("0"));////fJGlunzhongzuoJT.ToString();
                objmodellw.ylz = string.Format(@"{0}", flowbass.VAX_VWGHTRSP[0].ToString("0"));//fJGlunzhongyouJT.ToString();
                objmodellw.kzzh = string.Format(@"{0}", (flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0]).ToString("0"));// (fJGlunzhongzuo + fJGlunzhongyou).ToString();
                objmodellw.qhzzdl = dzhidongzuo1.ToString("0");
                objmodellw.qhyzdl = dzhidongyuo1.ToString("0");
                objmodellw.qczzdl = dzhidongchazuo1.ToString("0");
                objmodellw.qcyzdl = dzhidongchayuo1.ToString("0");
                objmodellw.dll = dBrakeF1.ToString("0.0");
                objmodellw.zdlpd = bBrakeF1 ? "1" : "2";
                objmodellw.bphl = BrakeDBF1.ToString("0.00");
                objmodellw.bphlpd = bBrakeDBF1 ? "1" : "2";
                objmodellw.zdpd = (bBrakeF1 && bBrakeDBF1) ? "1" : "2";
                if ((flowbass.sCllx.Contains("小型") || flowbass.sCllx.Contains("微型")) && (flowbass.sCllx.Contains("轿") || flowbass.sCllx.Contains("面包") || flowbass.sCllx.Contains("客")) || flowbass.sCllx.Contains("货") && flowbass.iCLZZL < 3500)
                {
                    objmodellw.zldtlh = dtdlunzhongzuo1.ToString("0");
                    objmodellw.yldtlh = dtdlunzhongyuo1.ToString("0");
                }
                else
                {
                    objmodellw.zldtlh = "";
                    objmodellw.yldtlh = "";
                }
                objmodellw.zdlqx = szdqxsj[0];
                objmodellw.clcsd = "7";
                if (flowbass.bnj)//综检不传
                {
                    flowbass.objajlwbass.write(flowbass.objcarclass, objmodellw, 0);
                    Thread.Sleep(1000);
                    //iml 0:四轮同检 1：前轴 2：后轴 3：只计算整车制动
                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        if (iml == 0)
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("PBB1", "结束", flowbass.gwjysbbh, flowbass.ipbzdqtongdao.ToString(), flowbass.objcarclass);
                        }
                        if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                        {
                            flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                        }
                    }
                    else
                    {
                        if (iml == 0)
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("STB1", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                        }
                        else
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("B1", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                        }
                        if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                        {
                            flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                        }
                    }
                }
                flowbass.getProcessfinish(flowbass.sDetectID, "B1");
            }
            if (iml == 2 || iml == 0)
            {
                //安检数据检测数据上传

                model.安检联网.modelB objmodellw = new model.安检联网.modelB();
                objmodellw.zlz = string.Format(@"{0}", flowbass.VAX_VWGHTLSP[1].ToString("0"));////fJGlunzhongzuoJT.ToString();
                objmodellw.ylz = string.Format(@"{0}", flowbass.VAX_VWGHTRSP[1].ToString("0"));//fJGlunzhongyouJT.ToString();
                objmodellw.kzzh = string.Format(@"{0}", (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]).ToString("0"));// (fJGlunzhongzuo + fJGlunzhongyou).ToString();
                objmodellw.qhzzdl = dzhidongzuo2.ToString("0");
                objmodellw.qhyzdl = dzhidongyuo2.ToString("0");
                objmodellw.qczzdl = dzhidongchazuo2.ToString("0");
                objmodellw.qcyzdl = dzhidongchayou2.ToString("0");
                objmodellw.dll = dBrakeF2.ToString("0.0");
                objmodellw.zdlpd = bBrakeF2 ? "1" : "2";
                objmodellw.bphl = BrakeDBF2.ToString("0.00");
                objmodellw.bphlpd = bBrakeDBF2 ? "1" : "2";
                objmodellw.zdpd = (bBrakeF2 && bBrakeDBF2) ? "1" : "2";
                if ((flowbass.sCllx.Contains("小型") || flowbass.sCllx.Contains("微型")) && (flowbass.sCllx.Contains("轿") || flowbass.sCllx.Contains("面包") || flowbass.sCllx.Contains("客")) || flowbass.sCllx.Contains("货") && flowbass.iCLZZL<3500)
                {
                objmodellw.zldtlh = dtdlunzhongzuo2.ToString("0");
                objmodellw.yldtlh = dtdlunzhongyuo2.ToString("0");
                }
                else
                {
                    objmodellw.zldtlh = "";
                    objmodellw.yldtlh = "";
                }
                objmodellw.zdlqx = szdqxsj[1];

                objmodellw.clcsd = "7";
                if (flowbass.bnj)//综检不传
                {
                   revert= flowbass.objajlwbass.write(flowbass.objcarclass, objmodellw, 1);
                   if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                   {
                       flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                   }
                    Thread.Sleep(1000);

                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        revert = flowbass.objajlwbass.SendJYXMKSSJ("PBB2", "结束", flowbass.gwjysbbh, flowbass.ipbzdhtongdao.ToString(), flowbass.objcarclass);
                        if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                        {
                            flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                        }
                    }
                    else
                    {
                        if (iml == 0)
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("STB2", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                        }
                        else
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("B2", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                        }
                        if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                        {
                            flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                        }
                    }
                }
                flowbass.getProcessfinish(flowbass.sDetectID, "B2");
            }
            #endregion
        }
        public void JudgeTotalResult38900(int iml)
        {
            //iml 0:四轮同检 1：前轴 2：后轴 3：只计算整车制动


            #region 计算制动力
            double dBrakeF1 = 0, BrakeDBF1 = 0, dBrakeDB1 = 0;//制动率 不平衡率 制动差
            double dBrakeF2 = 0, BrakeDBF2 = 0, dBrakeDB2 = 0;//制动率 不平衡率 制动差
            double dTotalWei = 0;
            if (iml == 1 || iml == 0)
            {
                if ((flowbass.sCllx.Contains("小型") || flowbass.sCllx.Contains("微型")) && (flowbass.sCllx.Contains("轿") || flowbass.sCllx.Contains("面包") || flowbass.sCllx.Contains("客")) || flowbass.sCllx.Contains("货") || flowbass.iCLZZL < 3500)
                {
                    dBrakeF1 = Math.Round(100 * (dzhidongzuo1 + dzhidongyuo1) / ((dtdlunzhongzuo1 + dtdlunzhongyuo1) > 1 ? (dtdlunzhongzuo1 + dtdlunzhongyuo1) * 0.98 : 1), 1);
                }
                else
                {
                    //dBrakeF1 = Math.Round(100 * (dzhidongzuo1 + dzhidongyuo1) / ((dlunzhongzuo1 + dlunzhongyuo1) > 1 ? (dlunzhongzuo1 + dlunzhongyuo1) * 0.98 : 1), 1);
                    dBrakeF1 = Math.Round(100 * (dzhidongzuo1 + dzhidongyuo1) / ((flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0]) > 1 ? (flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0]) * 0.98 : 1), 1);
                }
                dBrakeDB1 = Math.Abs(dzhidongchazuo1 - dzhidongchayuo1);
                BrakeDBF1 = Math.Round(100 * (dBrakeDB1) / ((dzhidongzuo1 > dzhidongyuo1) ? dzhidongzuo1 : dzhidongyuo1), 1);
            }
            if (iml == 2 || iml == 0)
            {

                if ((flowbass.sCllx.Contains("小型") || flowbass.sCllx.Contains("微型")) && (flowbass.sCllx.Contains("轿") || flowbass.sCllx.Contains("面包") || flowbass.sCllx.Contains("客")) || flowbass.sCllx.Contains("货") && flowbass.iCLZZL < 3500)
                {
                    dBrakeF2 = Math.Round(100 * (dzhidongzuo2 + dzhidongyuo2) / ((dtdlunzhongzuo2 + dtdlunzhongyuo2) > 1 ? (dtdlunzhongzuo2 + dtdlunzhongyuo2) * 0.98 : 1), 1);
                    dBrakeDB2 = Math.Abs(dzhidongchazuo2 - dzhidongchayou2);
                    if (dBrakeF2 < 60)
                    {
                        //BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((dlunzhongzuo2 + dlunzhongyuo2) > 1 ? (dlunzhongzuo2 + dlunzhongyuo2) * 0.98 : 1), 1);
                        BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) > 1 ? (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) * 0.98 : 1), 1);
                    }
                    else
                    {

                        BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((dzhidongzuo2 > dzhidongyuo2) ? dzhidongzuo2 : dzhidongyuo2), 1);
                    }
                }
                else
                {
                    //dBrakeF2 = Math.Round(100 * (dzhidongzuo2 + dzhidongyuo2) / ((dlunzhongzuo2 + dlunzhongyuo2) > 1 ? (dlunzhongzuo2 + dlunzhongyuo2) * 0.98 : 1), 1);
                    dBrakeF2 = Math.Round(100 * (dzhidongzuo2 + dzhidongyuo2) / ((flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) > 1 ? (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) * 0.98 : 1), 1);
                    dBrakeDB2 = Math.Abs(dzhidongchazuo2 - dzhidongchayou2);
                    if (dBrakeF2 < 60)
                    {
                        //BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((dlunzhongzuo2 + dlunzhongyuo2) > 1 ? (dlunzhongzuo2 + dlunzhongyuo2) * 0.98 : 1), 1);
                        BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) > 1 ? (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]) * 0.98 : 1), 1);
                    }
                    else
                    {
                        BrakeDBF2 = Math.Round(100 * (dBrakeDB2) / ((dzhidongzuo2 > dzhidongyuo2) ? dzhidongzuo2 : dzhidongyuo2), 1);
                    }
                }
            }
            if (iml == 3 || iml == 0)
            {
                //double dzhengchezd = dzhidongzuo1 + dzhidongyuo1 + dzhidongzuo2 + dzhidongyuo2;
                //double dzhengchelz = (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) > 0 ? (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) : 1;
                double dzhengchezd = (double)(flowbass.VAX_VBRAKEL[0] + flowbass.VAX_VBRAKER[0] + flowbass.VAX_VBRAKEL[1] + flowbass.VAX_VBRAKER[1]);
                double dzhengchelz = (double)(flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0] + flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]);
                dTotalWei = (double)(100 * dzhengchezd / (dzhengchelz * 0.98));
                dTotalWei = Math.Round(dTotalWei, 1);
                //dTotalWei = Math.Round(100 * (dzhengchezd) / ((dzhengchelz) * 0.98), 1);
            }
            #endregion
            #region 判定制动力与不平衡率是否合格
            bool bBrakeF1 = true;
            bool bBrakeDBF1 = true;
            bool bBrakeF2 = true;
            bool bBrakeDBF2 = true;
            bool bbrakezhengche = true;
            double fzdlxz1 = 0, fbphlxz1 = 0;
            double fzdlxz2 = 0, fbphlxz2 = 0;
            if (iml == 1 || iml == 0)
            {
                //制动率
                if (dBrakeF1 < flowbass.STD_FBRAKE)
                {
                    bBrakeF1 = false;
                }
                //不平衡率
                if (BrakeDBF1 > flowbass.STD_FBRAKEDIF)
                {
                    bBrakeDBF1 = false;
                }
                fzdlxz1 = flowbass.STD_FBRAKE;
                fbphlxz1 = flowbass.STD_FBRAKEDIF;

                if (!bBrakeF1 || !bBrakeDBF1)
                {
                    flowbass.getbuhge(flowbass.sDetectID, "B1");
                }
                else
                {
                    flowbass.sethege(flowbass.sDetectID, "B1");
                }


            }
            if (iml == 2 || iml == 0)
            {
                //制动率
                if (dBrakeF2 < flowbass.STD_BRAKE2)
                {
                    bBrakeF2 = false;
                }
                //不平衡率
                if (dBrakeF2 >= 60)
                {
                    if (BrakeDBF2 > flowbass.STD_BBRAKEDIF1)
                    {
                        bBrakeDBF2 = false;
                    }
                    fzdlxz2 = flowbass.STD_BRAKE2;
                    fbphlxz2 = flowbass.STD_BBRAKEDIF1;
                }
                else
                {
                    if (BrakeDBF2 > flowbass.STD_BBRAKEDIF2)
                    {
                        bBrakeDBF2 = false;
                    }
                    fzdlxz2 = flowbass.STD_BRAKE2;
                    fbphlxz2 = flowbass.STD_BBRAKEDIF2;
                }

                if (!bBrakeF2 || !bBrakeDBF2)
                {
                    flowbass.getbuhge(flowbass.sDetectID, "B2");
                }
                else
                {
                    flowbass.sethege(flowbass.sDetectID, "B2");
                }
            }
            if (iml == 3 || iml == 0)
            {
                if (dTotalWei < flowbass.STD_BRAKEF)
                {
                    bbrakezhengche = false;
                }
            }
            #endregion


            #region 灯牌显示
            if (iml == 1 || iml == 0)
            {
                string sdpxss = "";
                string sdpxsx = "";

                sdpxss = string.Format("1轴制动力");
                sdpxsx = string.Format("左{0} 右{1}", (int)dzhidongzuo1, (int)dzhidongyuo1);
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                Thread.Sleep(xssj);

                sdpxss = string.Format("1轴制动率{0}%", dBrakeF1);
                sdpxsx = string.Format("{0}", bBrakeF1 ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);

                sdpxss = string.Format("1轴不平衡差值");
                sdpxsx = string.Format("左{0} 右{1}", (int)dzhidongchazuo1, (int)dzhidongchayuo1);
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                Thread.Sleep(xssj);

                sdpxss = string.Format("1轴不平衡率{0}", BrakeDBF1);
                sdpxsx = string.Format("{0}", bBrakeDBF1 ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);
                sdpxss = string.Format("1轴制动判定");
                sdpxsx = string.Format("{0}", (bBrakeF1 && bBrakeDBF1) ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);
            }
            if (iml == 2 || iml == 0)
            {
                string sdpxss = "";
                string sdpxsx = "";

                sdpxss = string.Format("2轴制动力");
                sdpxsx = string.Format("左{0} 右{1}", (int)dzhidongzuo2, (int)dzhidongyuo2);
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                Thread.Sleep(xssj);

                sdpxss = string.Format("2轴制动率{0}", dBrakeF2);
                sdpxsx = string.Format("{0}", bBrakeF2 ? "合格" : "不合格");

                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);

                sdpxss = string.Format("2轴不平衡差值");
                sdpxsx = string.Format("左{0} 右{1}", (int)dzhidongchazuo2, (int)dzhidongchayou2);
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                Thread.Sleep(xssj);

                sdpxss = string.Format("2轴不平衡率{0}%", BrakeDBF2);
                sdpxsx = string.Format("{0}", bBrakeDBF2 ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);
                sdpxss = string.Format("2轴制动判定");
                sdpxsx = string.Format("{0}", (bBrakeF2 && bBrakeDBF2) ? "合格" : "不合格");
                flowbass.LedWrite(sdpxss, sdpxsx, 1);
                sxinxixianshi = sdpxss + "," + sdpxsx;
                showxianshi();
                Thread.Sleep(xssj);
            }
            if (iml == 3 || iml == 0)
            {
                string sdps = string.Format("整车制动率{0}%", dTotalWei);
                string sdpx = string.Format("{0}", bbrakezhengche ? "合格" : "不合格");
                flowbass.LedWrite(sdps, sdpx, 1);
                sxinxixianshi = sdps + "," + sdpx;
                showxianshi();
                Thread.Sleep(xssj);
                if (!bbrakezhengche)
                {
                    bool bybhg = false;

                    for (int i = 0; i < flowbass.iVax; i++)
                    {
                        if (flowbass.getfjxm(flowbass.sDetectID, string.Format("B{0}", i + 1)))
                            bybhg = true;
                    }
                    if (!bybhg)
                    {
                        for (int i = 0; i < flowbass.iVax; i++)
                        {
                            flowbass.getbuhge(flowbass.sDetectID, string.Format("B{0}", i + 1));
                        }
                    }
                }
            }
            #endregion

            #region 写入数据库
            if (iml == 1 || iml == 0)
            {
                //制动差
                flowbass.AddData(flowbass.sDetectID, "DET_BRIKEDIFFJL1", "Detects_SJB", bBrakeDBF1 ? 1 : 2);
                //制动和
                flowbass.AddData(flowbass.sDetectID, "DET_BRIKEFJL1", "Detects_SJB", bBrakeF1 ? 1 : 2);
                //轴总评价
                flowbass.AddData(flowbass.sDetectID, "DET_ZZJL1", "Detects_SJB", (bBrakeDBF1 && bBrakeF1) ? 1 : 2);

                flowbass.editData(flowbass.sDetectID, "DET_BRIKEQX1", "Detects_SJB", listzdz1, listzdy1); //  //曲线

                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTZ1", "Detects_SJB", flowbass.VAX_VWGHTLSP[0].ToString("0")); //轴重左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTY1", "Detects_SJB", flowbass.VAX_VWGHTRSP[0].ToString("0")); //轴重右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTH1", "Detects_SJB", (flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0]).ToString("0")); //轴重
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTZDT1", "Detects_SJB", dtdlunzhongzuo1.ToString("0")); //轴重左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTYDT1", "Detects_SJB", dtdlunzhongyuo1.ToString("0")); //轴重右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTHDT1", "Detects_SJB", (dtdlunzhongzuo1 + dtdlunzhongyuo1).ToString("0")); //动态轴荷和
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEL1", "Detects_SJB", dzhidongzuo1.ToString("0")); //制动力左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEY1", "Detects_SJB", dzhidongyuo1.ToString("0")); //制动力右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKE1", "Detects_SJB", (dzhidongzuo1 + dzhidongyuo1).ToString("0")); //制动和
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRIKEF1", "Detects_SJB", dBrakeF1.ToString("0.0")); //制动因数
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFC1", "Detects_SJB", (Math.Abs(dzhidongchazuo1 - dzhidongchayuo1)).ToString("0")); //制动差
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRIKEDIFF1", "Detects_SJB", BrakeDBF1.ToString("0.0")); //制动差因素
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFZ1", "Detects_SJB", dzhidongchazuo1.ToString("0")); //制动差左点
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFY1", "Detects_SJB", dzhidongchayuo1.ToString("0")); //制动差右点


                string jielun = "";
                jielun = string.Format(@"{0},{1},{2},{3}",
                                        string.Format("{0}轴制动率/不平衡率(%)", 1),
                                        string.Format("{0}/{1}", dBrakeF1.ToString("0.0"), BrakeDBF1.ToString("0.0")),
                                        string.Format("≥{0}/≤{1}", fzdlxz1, fbphlxz1),
                                        string.Format("{0}/{1}", bBrakeF1 ? "合格" : "不合格", bBrakeDBF1 ? "合格" : "不合格")
                                        );
                flowbass.AddData(flowbass.sDetectID, "PD_BRIKE1", "PD_AJ", jielun);
                //listzdz1[icount], listzdy1[icount]
            }
            if (iml == 2 || iml == 0)
            {
                //制动差
                flowbass.AddData(flowbass.sDetectID, "DET_BRIKEDIFFJL2", "Detects_SJB", bBrakeDBF2 ? 1 : 2);
                //制动和
                flowbass.AddData(flowbass.sDetectID, "DET_BRIKEFJL2", "Detects_SJB", bBrakeF2 ? 1 : 2);
                //轴总评价
                flowbass.AddData(flowbass.sDetectID, "DET_ZZJL2", "Detects_SJB", (bBrakeDBF2 && bBrakeF2) ? 1 : 2);
                flowbass.editData(flowbass.sDetectID, "DET_BRIKEQX2", "Detects_SJB", listzdz2, listzdy2); //  //曲线
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTZ2", "Detects_SJB", flowbass.VAX_VWGHTLSP[1].ToString("0")); //轴重左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTY2", "Detects_SJB", flowbass.VAX_VWGHTRSP[1].ToString("0")); //轴重右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTH2", "Detects_SJB", (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]).ToString("0")); //轴重
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTZDT2", "Detects_SJB", dtdlunzhongzuo2.ToString("0")); //轴重左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTYDT2", "Detects_SJB", dtdlunzhongyuo2.ToString("0")); //轴重右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTHDT2", "Detects_SJB", (dtdlunzhongzuo2 + dtdlunzhongyuo2).ToString("0")); //动态轴荷和
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEL2", "Detects_SJB", dzhidongzuo2.ToString("0")); //制动力左
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEY2", "Detects_SJB", dzhidongyuo2.ToString("0")); //制动力右
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKE2", "Detects_SJB", (dzhidongzuo2 + dzhidongyuo2).ToString("0")); //制动和
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRIKEF2", "Detects_SJB", dBrakeF2.ToString("0.0")); //制动因数
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFC2", "Detects_SJB", (Math.Abs(dzhidongchazuo2 - dzhidongchayou2)).ToString("0")); //制动差
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRIKEDIFF2", "Detects_SJB", BrakeDBF2.ToString("0.0")); //制动差因素
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFZ2", "Detects_SJB", dzhidongchazuo2.ToString("0")); //制动差左点
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEDIFY2", "Detects_SJB", dzhidongchayou2.ToString("0")); //制动差右点

                string jielun = "";
                jielun = string.Format(@"{0},{1},{2},{3}",
                                        string.Format("{0}轴制动率/不平衡率(%)", 2),
                                        string.Format("{0}/{1}", dBrakeF2.ToString("0.0"), BrakeDBF2.ToString("0.0")),
                                        string.Format("≥{0}/≤{1}", fzdlxz2, fbphlxz2),
                                        string.Format("{0}/{1}", bBrakeF2 ? "合格" : "不合格", bBrakeDBF2 ? "合格" : "不合格")
                                        );
                flowbass.AddData(flowbass.sDetectID, "PD_BRIKE2", "PD_AJ", jielun);

            }
            if (iml == 3 || iml == 0)
            {
                //double dzhengchezd = dzhidongzuo1 + dzhidongyuo1 + dzhidongzuo2 + dzhidongyuo2;
                //double dzhengchelz = (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) > 0 ? (dlunzhongzuo1 + dlunzhongyuo1 + dlunzhongzuo2 + dlunzhongyuo2) : 1;
                double dzhengchezd = (double)(flowbass.VAX_VBRAKEL[0] + flowbass.VAX_VBRAKER[0] + flowbass.VAX_VBRAKEL[1] + flowbass.VAX_VBRAKER[1]);
                double dzhengchelz = (double)(flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0] + flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]);

                flowbass.AddData(flowbass.sDetectID, "DET_ZCJL", "Detects_SJB", bbrakezhengche ? 1 : 2);
                //保存数据
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKE", "Detects_SJB", dzhengchezd.ToString("0"));
                flowbass.AddData_Check(flowbass.sDetectID, "DET_BRAKEF", "Detects_SJB", dTotalWei.ToString("0.0"));
                flowbass.AddData_Check(flowbass.sDetectID, "DET_WEIGHTHZC", "Detects_SJB", dzhengchelz.ToString("0")); //整车重量

                //检测结束
                string jielun = "";
                jielun = string.Format(@"{0},{1},{2},{3}",
                                        string.Format("整车制动率(%)"),
                                        string.Format("{0}", dTotalWei.ToString("0.0")),
                                        string.Format("≥{0}", flowbass.STD_BRAKEF),
                                        string.Format("{0}", bbrakezhengche ? "合格" : "不合格")
                                        );
                flowbass.AddData(flowbass.sDetectID, "PD_zhengche", "PD_AJ", jielun);
                if (flowbass.bzj)
                {
                    flowbass.AddData(flowbass.sDetectID, "PD_zhengche", "PD_ZJ", jielun);
                }

            }
            #endregion


            #region 联网上传
            if (iml == 1 || iml == 0)
            {
                //安检数据检测数据上传
                model.安检联网.modelB objmodellw = new model.安检联网.modelB();
                objmodellw.zlz = string.Format(@"{0}", flowbass.VAX_VWGHTLSP[0].ToString("0"));////fJGlunzhongzuoJT.ToString();
                objmodellw.ylz = string.Format(@"{0}", flowbass.VAX_VWGHTRSP[0].ToString("0"));//fJGlunzhongyouJT.ToString();
                objmodellw.kzzh = string.Format(@"{0}", (flowbass.VAX_VWGHTLSP[0] + flowbass.VAX_VWGHTRSP[0]).ToString("0"));// (fJGlunzhongzuo + fJGlunzhongyou).ToString();
                objmodellw.qhzzdl = dzhidongzuo1.ToString("0");
                objmodellw.qhyzdl = dzhidongyuo1.ToString("0");
                objmodellw.qczzdl = dzhidongchazuo1.ToString("0");
                objmodellw.qcyzdl = dzhidongchayuo1.ToString("0");
                objmodellw.dll = dBrakeF1.ToString("0.0");
                objmodellw.zdlpd = bBrakeF1 ? "1" : "2";
                objmodellw.bphl = BrakeDBF1.ToString("0.00");
                objmodellw.bphlpd = bBrakeDBF1 ? "1" : "2";
                objmodellw.zdpd = (bBrakeF1 && bBrakeDBF1) ? "1" : "2";
                if ((flowbass.sCllx.Contains("小型") || flowbass.sCllx.Contains("微型")) && (flowbass.sCllx.Contains("轿") || flowbass.sCllx.Contains("面包") || flowbass.sCllx.Contains("客")) || flowbass.sCllx.Contains("货") && flowbass.iCLZZL < 3500)
                {
                    objmodellw.zldtlh = dtdlunzhongzuo1.ToString("0");
                    objmodellw.yldtlh = dtdlunzhongyuo1.ToString("0");
                }
                else
                {
                    objmodellw.zldtlh = "";
                    objmodellw.yldtlh = "";
                }
                objmodellw.zdlqx = szdqxsj[0];

                objmodellw.clcsd = "7";
                if (flowbass.bnj)//综检不传
                {
                    flowbass.objajlwbass.write(flowbass.objcarclass, objmodellw, 0);
                    Thread.Sleep(1000);

                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        revert = flowbass.objajlwbass.SendJYXMKSSJ("PBB1", "结束", flowbass.gwjysbbh, flowbass.ipbzdqtongdao.ToString(), flowbass.objcarclass);
                        if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                        {
                            flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                        }
                    }
                    else
                    {
                        if (iml == 0)
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("STB1", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                        }
                        else
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("B1", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                        }
                        if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                        {
                            flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                        }
                    }
                }
                flowbass.getProcessfinish(flowbass.sDetectID, "B1");
            }
            if (iml == 2 || iml == 0)
            {
                //安检数据检测数据上传

                model.安检联网.modelB objmodellw = new model.安检联网.modelB();
                objmodellw.zlz = string.Format(@"{0}", flowbass.VAX_VWGHTLSP[1].ToString("0"));////fJGlunzhongzuoJT.ToString();
                objmodellw.ylz = string.Format(@"{0}", flowbass.VAX_VWGHTRSP[1].ToString("0"));//fJGlunzhongyouJT.ToString();
                objmodellw.kzzh = string.Format(@"{0}", (flowbass.VAX_VWGHTLSP[1] + flowbass.VAX_VWGHTRSP[1]).ToString("0"));// (fJGlunzhongzuo + fJGlunzhongyou).ToString();
                objmodellw.qhzzdl = dzhidongzuo2.ToString("0");
                objmodellw.qhyzdl = dzhidongyuo2.ToString("0");
                objmodellw.qczzdl = dzhidongchazuo2.ToString("0");
                objmodellw.qcyzdl = dzhidongchayou2.ToString("0");
                objmodellw.dll = dBrakeF2.ToString("0.0");
                objmodellw.zdlpd = bBrakeF2 ? "1" : "2";
                objmodellw.bphl = BrakeDBF2.ToString("0.00");
                objmodellw.bphlpd = bBrakeDBF2 ? "1" : "2";
                objmodellw.zdpd = (bBrakeF2 && bBrakeDBF2) ? "1" : "2";
                if ((flowbass.sCllx.Contains("小型") || flowbass.sCllx.Contains("微型")) && (flowbass.sCllx.Contains("轿") || flowbass.sCllx.Contains("面包") || flowbass.sCllx.Contains("客")) || flowbass.sCllx.Contains("货") && flowbass.iCLZZL < 3500)
                {
                    objmodellw.zldtlh = dtdlunzhongzuo2.ToString("0");
                    objmodellw.yldtlh = dtdlunzhongyuo2.ToString("0");
                }
                else
                {
                    objmodellw.zldtlh = "";
                    objmodellw.yldtlh = "";
                }
                objmodellw.zdlqx = szdqxsj[1];

                objmodellw.clcsd = "7";
                if (flowbass.bnj)//综检不传
                {
                    revert = flowbass.objajlwbass.write(flowbass.objcarclass, objmodellw, 1);
                    if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                    {
                        flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                    }
                    Thread.Sleep(1000);

                    if (flowbass.sjcbz.Contains("38900"))
                    {
                        revert = flowbass.objajlwbass.SendJYXMKSSJ("PBB2", "结束", flowbass.gwjysbbh, flowbass.ipbzdhtongdao.ToString(), flowbass.objcarclass);
                        
                        if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                        {
                            flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                        }
                    }
                    else
                    {
                        if (iml == 0)
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("STB2", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                        }
                        else
                        {
                            revert = flowbass.objajlwbass.SendJYXMKSSJ("B2", "结束", flowbass.gwjysbbh, flowbass.ibrtongdao.ToString(), flowbass.objcarclass);
                        }
                        if (!(revert.Length > 0 && revert[0].ToString() == "1"))
                        {
                            flowbass.LedWrite("联网失败", revert, 1); Thread.Sleep(2000);
                        }
                    }
                }
                flowbass.getProcessfinish(flowbass.sDetectID, "B2");
            }
            #endregion
        }
        string sxinxixianshi = "";
        private void showxianshi()
        {
            if (this.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showxianshi);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                xinxixianshi.Text = sxinxixianshi;
            }
        }
        private void showlunzhongzuo1()
        {
            if (this.gauge_weight_left.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showlunzhongzuo1);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_weight_left.Visible = true;
                this.digitalGauge3.DigitCount = xsdlunzhongzuo1.ToString().Length < 3 ? 3 : xsdlunzhongzuo1.ToString().Length;
                this.digitalGauge3.Text = xsdlunzhongzuo1.ToString();
               // lunzhongzou1.Text = xsdlunzhongzuo1.ToString();
            }
        }
        private void showlunzhongyuo1()
        {
            if (this.gauge_weight_right.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showlunzhongyuo1);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_weight_right.Visible = true;
                this.digitalGauge4.DigitCount = xsdlunzhongyuo1.ToString().Length < 3 ? 3 : xsdlunzhongyuo1.ToString().Length;
                this.digitalGauge4.Text = xsdlunzhongyuo1.ToString();
               // lunzhongyou1.Text = xsdlunzhongyuo1.ToString();
            }
        }
        private void showlunzhongzuo2()
        {
            if (this.gauge_weighth_left.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showlunzhongzuo2);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_weighth_left.Visible = true;
                this.digitalGauge7.DigitCount = xsdlunzhongzuo2.ToString().Length < 3 ? 3 : xsdlunzhongzuo2.ToString().Length;
                this.digitalGauge7.Text = xsdlunzhongzuo2.ToString();
               // lunzhongzou2.Text = xsdlunzhongzuo2.ToString();
            }
        }
        private void showlunzhongyuo2()
        {
            if (this.gauge_weighth_right.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showlunzhongyuo2);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_weighth_right.Visible = true;
                this.digitalGauge8.DigitCount = xsdlunzhongyuo2.ToString().Length < 3 ? 3 : xsdlunzhongyuo2.ToString().Length;
                this.digitalGauge8.Text = xsdlunzhongyuo2.ToString();
               // lunzhongyou2.Text = xsdlunzhongyuo2.ToString();
            }
        }
        private void showzhidongzuo1()
        {
            if (this.gauge_braking_left.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showzhidongzuo1);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_braking_left.Visible = true;
                this.digitalGauge1.DigitCount = xsdzhidongzuo1.ToString().Length < 3 ? 3 : xsdzhidongzuo1.ToString().Length;
                this.digitalGauge1.Text = xsdzhidongzuo1.ToString();
                //zhidonglizuo1.Text = xsdzhidongzuo1.ToString();
            }
        }
        private void showzhidongyuo1()
        {
            if (this.gauge_braking_right.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showzhidongyuo1);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_braking_right.Visible = true;
                this.digitalGauge2.DigitCount = xsdzhidongyuo1.ToString().Length < 3 ? 3 : xsdzhidongyuo1.ToString().Length;
                this.digitalGauge2.Text = xsdzhidongyuo1.ToString();
               // zhidongliyou1.Text = xsdzhidongyuo1.ToString();
            }
        }
        private void showzhidongzuo2()
        {
            if (this.gauge_brakingh_left.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showzhidongzuo2);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_brakingh_left.Visible = true;
                this.digitalGauge5.DigitCount = xsdzhidongzuo2.ToString().Length < 3 ? 3 : xsdzhidongzuo2.ToString().Length;
                this.digitalGauge5.Text = xsdzhidongzuo2.ToString();
               // zhidonglizuo2.Text = xsdzhidongzuo2.ToString();
            }
        }
        private void showzhidongyuo2()
        {
            if (this.gauge_brakingh_right.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(showzhidongyuo2);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.gauge_brakingh_right.Visible = true;
                this.digitalGauge6.DigitCount = xsdzhidongyuo2.ToString().Length < 3 ? 3 : xsdzhidongyuo2.ToString().Length;
                this.digitalGauge6.Text = xsdzhidongyuo2.ToString();
                //zhidongliyou2.Text = xsdzhidongyuo2.ToString();
            }
        }
        public void showsj()
        {
            showlunzhongzuo1();
            showlunzhongyuo1();
            showlunzhongzuo2();
            showlunzhongyuo2();
            showzhidongzuo1();
            showzhidongyuo1();
            showzhidongzuo2();
            showzhidongyuo2();
        }
        public void showsjqian()
        {
            showlunzhongzuo1();
            showlunzhongyuo1();
            showzhidongzuo1();
            showzhidongyuo1();
        }


        public void showsjhou()
        {
            showlunzhongzuo2();
            showlunzhongyuo2();
            showzhidongzuo2();
            showzhidongyuo2();
        }

        private void but_alone_Click(object sender, EventArgs e)
        {
            sdjcs = true;
        }

        public void Thread1()
        {
            try
            {
              //  m_mainform.DAC.tiaoling(1);
                flowbass.getlunzhong();
               // ShowControls(true);
                StratTest();
                flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "平板检测结束", flowbass.sDetectID);
                flowbass.Updatejcxhao(flowbass.objcarclass.jcxdh, flowbass.sDetectID);
                if (jcxjs)
                {
                    flowbass.LedWrite(flowbass.sPlate, "检测线完成", 1);
                    flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "检测线完成", flowbass.sDetectID);
                    Thread.Sleep(xssj);
                }
                if (flowbass.LastProcessnew(int.Parse(flowbass.sDetectID)) && !flowbass.ifinish)
                {
                    //flowbass.objajlwbass.sendAJend(flowbass.jylsh, false);
                    flowbass.LedWrite("正在发送", "联网总结束", 1);
                    string slianwangfanhui = flowbass.objajlwbass.sendAJend(flowbass.jylsh, false, flowbass.bzj);
                    if (!(slianwangfanhui.Length > 0 && slianwangfanhui[0].ToString() == "1"))
                    {
                        flowbass.LedWrite("联网失败", slianwangfanhui, 1);
                    }
                    else
                    {
                        flowbass.LedWrite("发送完成", "", 1);
                        flowbass.UpdateLoginRecord(DateTime.Now.ToString(), "检测线完成", flowbass.sDetectID);
                    }
                    Thread.Sleep(2000);
                }
                flowbass.LedWrite(flowbass.sgongwei, "", 1);
                sxinxixianshi = flowbass.sgongwei;
                showxianshi();
                end();
                //t1.Abort();
                //t1.DisableComObjectEagerCleanup();

            }
            catch (Exception ex)
            {
                //错误日记 记录到当天日期下目录中
                if (!(ex is System.Threading.ThreadAbortException))
                {
                    flowbass.LedWrite(flowbass.sPlate, "异常,停止检测", 1);
                    m_mainform.baocunriji("平板", ex.Message.ToString());
                    m_mainform.SaveErrorLog("平板检测流程", ex.Message.ToString());//problem
                    closeform();
                }
            }
           
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (flowbass.izhuangtai == 2)
                {
                    m_mainform.objyibiaobass.select(flowbass.sshebei);
                    m_mainform.bpanelshow = true;
                    m_mainform.showpanel();
                    flowbass.izhuangtai = 1;
                    //Thread tt = new Thread(end);
                    //tt.Start();
                    flowbass.IsReadyForStart();
                    //bianliangchushihua();
                    t1 = new Thread(new ThreadStart(Thread1));
                    t1.Start();
                    //this.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                m_mainform.baocunriji("平板打开窗体失败", ex.Message.ToString());
                m_mainform.SaveErrorLog("平板打开窗体", ex.Message.ToString());//problem

            }
        }

        public void sethongwai1(bool bdi)
        {
            try
            {
                if (!bdi)
                {

                    lblhongwai1.ForeColor = Color.Green;
                }
                else
                {


                    lblhongwai1.ForeColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public void sethongwai2(bool bdi)
        {
            try
            {
                if (!bdi)
                {

                    lblhongwai2.ForeColor = Color.Green;
                }
                else
                {


                    lblhongwai2.ForeColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        bool bjd = false;
        private void timer2_Tick(object sender, EventArgs e)
        {
            try
            {
                m_mainform.sethongwai(lblhongwai1, m_mainform.WaitEventZT(iFLHWQ, bhongwaiqf[iFLHWQ], ihongwaidwsj[iFLHWQ]));
                m_mainform.sethongwai(lblhongwai2, m_mainform.WaitEventZT(iFLHWH, bhongwaiqf[iFLHWH], ihongwaidwsj[iFLHWH]));
                m_mainform.sethongwai(toolStripLabel2, m_mainform.WaitEventZT(iFLHWQ, bhongwaiqf[iFLHWQ], ihongwaidwsj[iFLHWQ]));
                m_mainform.sethongwai(toolStripLabel4, m_mainform.WaitEventZT(iFLHWH, bhongwaiqf[iFLHWH], ihongwaidwsj[iFLHWH]));
                if (bjd)
                {

                    dAIlunzhongzuo1 = m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo1]) - m_mainform.DAC.getjsz("平板前轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo1]);
                    dAIlunzhongyuo1 = m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo1]) - m_mainform.DAC.getjsz("平板前轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo1]);
                    dAIzhidongzuo1 = m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo1]) - m_mainform.DAC.getjsz("平板前制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo1]);
                    dAIzhidongyuo1 = m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo1]) - m_mainform.DAC.getjsz("平板前制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo1]);
                    dAIlunzhongzuo2 = m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataSU[iAIlunzhongzuo2]) - m_mainform.DAC.getjsz("平板后轮重左", m_mainform.DAC.fAIDataZero[iAIlunzhongzuo2]);
                    dAIlunzhongyuo2 = m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataSU[iAIlunzhongyuo2]) - m_mainform.DAC.getjsz("平板后轮重右", m_mainform.DAC.fAIDataZero[iAIlunzhongyuo2]);
                    dAIzhidongzuo2 = m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataSU[iAIzhidongzuo2]) - m_mainform.DAC.getjsz("平板后制动左", m_mainform.DAC.fAIDataZero[iAIzhidongzuo2]);
                    dAIzhidongyuo2 = m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataSU[iAIzhidongyuo2]) - m_mainform.DAC.getjsz("平板后制动右", m_mainform.DAC.fAIDataZero[iAIzhidongyuo2]);

                    dAIlunzhongzuo1 = Math.Round(dAIlunzhongzuo1);
                    dAIlunzhongyuo1 = Math.Round(dAIlunzhongyuo1);
                    dAIzhidongzuo1 = Math.Round(dAIzhidongzuo1);
                    dAIzhidongyuo1 = Math.Round(dAIzhidongyuo1);
                    dAIlunzhongzuo2 = Math.Round(dAIlunzhongzuo2);
                    dAIlunzhongyuo2 = Math.Round(dAIlunzhongyuo2);
                    dAIzhidongzuo2 = Math.Round(dAIzhidongzuo2);
                    dAIzhidongyuo2 = Math.Round(dAIzhidongyuo2);

                    xsdlunzhongzuo1 = dAIlunzhongzuo1;
                    xsdlunzhongyuo1 = dAIlunzhongyuo1;
                    xsdlunzhongzuo2 = dAIlunzhongzuo2;
                    xsdlunzhongyuo2 = dAIlunzhongyuo2;
                    xsdzhidongzuo1 = dAIzhidongzuo1;
                    xsdzhidongyuo1 = dAIzhidongyuo1;
                    xsdzhidongzuo2 = dAIzhidongzuo2;
                    xsdzhidongyuo2 = dAIzhidongyuo2;
                    showsj();
                }
            }
            catch
            { }
        }

        private void 仪表设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            工位配置.FLsetting f = new 工位配置.FLsetting();
            f.ShowDialog();
        }


        private void 显示控件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowControls(true);
        }
        public void ShowControls(bool flag)
        {

           
            label1.Visible = flag;
            label2.Visible = flag;
            label3.Visible = flag;
            label4.Visible = flag;
            label5.Visible = flag;
            label6.Visible = flag;
            label7.Visible = flag;
            label8.Visible = flag;

            gauge_braking_left.Visible = flag;
            gauge_braking_right.Visible = flag;
            gauge_weight_left.Visible = flag;
            gauge_weight_right.Visible = flag;
            lblhongwai1.Visible = flag;

            gauge_brakingh_left.Visible = flag;
            gauge_brakingh_right.Visible = flag;
            gauge_weighth_left.Visible = flag;
            gauge_weighth_right.Visible = flag;
            lblhongwai2.Visible = flag;
            groupBox3.Visible = flag;


        }
        public void ShowButtons(bool flag)
        {
            but_alone.Visible = flag;
            but_tiaoling.Visible = flag;
            but_tiaoling.Visible = flag;
        }

        private void 设备检定ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            xinxixianshi.Text = "正在检定";
            bjd = true;

        }

        private void 取消检定ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            xinxixianshi.Text = "平板制动检测";
            bjd = false;
        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            m_mainform.DAC.tiaoling(1);
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //sdjcs = true;
            m_mainform.DAC.setsjjl(true, flowbass.sPlate + DateTime.Now.ToString("MMddHHmmss"));//开始记录信号板信息
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            m_mainform.DAC.tiaoling(1);
        }

        private void TESTFL_Shown(object sender, EventArgs e)
        {
            try
            {
                float newx = (this.Width) / x;
                float newy = (this.Height) / y;
                setControls(newx, newy, this);
                ShowControls(false);
                ShowButtons(false);
                this.BackgroundImage = Image.FromFile(@"./ico/平板背景.jpg");
                this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            }
            catch (Exception ex)
            {

                m_mainform.baocunriji("平板Load失败", ex.Message.ToString());//problem
                m_mainform.SaveErrorLog("平板Load失败", ex.Message.ToString());//problem

            }
        }





        //---------------------------------------
    }

}
